Search Results

Search found 13135 results on 526 pages for 'actor model'.

Page 104/526 | < Previous Page | 100 101 102 103 104 105 106 107 108 109 110 111  | Next Page >

  • How do I model teams and gameplay in this scorekeeping application?

    - by Eric Hill
    I'm writing a scorekeeping application for card game that has a few possibly-interesting constraints. The application accepts user registrations for players, then lets them check-in to a particular game (modeled as Event). After the final player registers, the app should generate teams, singles or doubles, depending on the preference of the person running the game and some validations (can't do doubles if there's an odd number checked in). There are @event.teams.count rounds in the game. To sum up: An event consists of `@event.teams.count` rounds; Teams can have 1 or more players Events have n or n/2 teams (depending on whether it's singles or doubles) Users will be members of different teams at different events Currently I have a rat's nest of associations: class User < ActiveRecord::Base has_many :teams, :through => :players has_many :events, :through => :teams class Event < ActiveRecord::Base has_many :rounds has_many :teams has_many :players, :through => :teams class Player < ActiveRecord::Base belongs_to :user belongs_to :team end class Team < ActiveRecord::Base has_many :players belongs_to :event end class Round < ActiveRecord::Base belongs_to :event belongs_to :user end The sticky part is team generation. I have basically a "start game" button that should freeze the registrations and pair up teams either singly or doubly, and render to Round#new so that the first (and subsequent) matches can be scored. Currently I'm implementing this as a check on Round#new that calls Event#generate_teams and displays the view: # Event#generate_teams def generate_teams # User has_many :events, :through => :registrations # self.doubles is a boolean denoting 2 players per team registrations.in_groups_of(self.doubles ? 2 : 1, nil).each do |side| self.teams << Player.create(self,side) end end Which doesn't work. Should there maybe be a Game model that ties everything together rather than (my current method) defining the game as an abstraction via the relationships between Events, Users, and Rounds (and Teams and Players and etc.)? My head is swimming.

    Read the article

  • how to store/model users/faceboook users/linkedin users, etc, with ActiveRecord?

    - by crankharder
    My app has "normal" users: those which come through a typical signup page facebook(FB) users: those which come from Facebook connect "FB-normal" users: a user that can log with both email/password * FB connect Further, there's the a slew of other openID-ish login methods (I don't think openID itself will be acceptable since it doesn't link up the accounts and allow the 3rd party specific features (posting to twitter, adding a FB post, etc etc)) So, how do I model this? Right now we have User class with #facebook_user? defined -- but it gets messy with the "FB-normal" users - plus all the validations become very tricky and hard to interpret. Also, there are methods like #deliver_password_reset! which make no sense in the context for facebook-only users. (this is lame) I've thought out STI (User::Facebook, User::Normal, User::FBNormal, etc.) This makes validations super slick, but it doesn't scale to other connection types, and all the permutations between them... User::FacebookLinkedInNormal(wtf?) Doing this with a bunch of modules I think would suck a lot. Any other ideas?

    Read the article

  • Accessing a share point site using the object model.

    - by Prashanth
    Hi I am trying to access a share point site using the SP object model from a console application. I am trying to do something like this.. SPSite site = new SPSite(sitePath) //Operations go here This works fine when the share point site and the console app are on the same machine. However when the console app and the site are on different machines, I get an error "The Web application at "http://server/url" could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application" Here are the things that I have already done: 1) I have tried accessing the site via both IP address as well as machine name, assuming that it could be a DNS resolution issue. 2) Initially I impersonated using a farm admin account, still i could not access. Then I added myself as the farm admin, still no joy. 4) The site is accessible via IE. So it is not a permission issue I guess. 5) I have tried almost all the solutions suggested by various links obtained by googling the error message. I am trying this on share point 2010. A similar issue occurs on 2007 also. Sometimes its kind of frustrating to do SharePoint development , since I get the feeling of stumbling from one error to the next, with no clue as to what could be wrong and the error messages not being helpful in the least :(

    Read the article

  • how does one _model_ data from relational databases in clojure ?

    - by sandeep
    I have asked this question on twitter as well the #clojure IRC channel, yet got no responses. There have been several articles about Clojure-for-Ruby-programmers, Clojure-for-lisp-programmers.. but what is the missing part is Clojure for ActiveRecord programmers . There have been articles about interacting with MongoDB, Redis, etc. - but these are key value stores at the end of the day. However, coming from a Rails background, we are used to thinking about databases in terms of inheritance - has_many, polymorphic, belongs_to, etc. The few articles about Clojure/Compojure + MySQL (ffclassic) - delve right into sql. Of course, it might be that an ORM induces impedence mismatch, but the fact remains that after thinking like ActiveRecord, it is very difficult to think any other way. I believe that relational DBs, lend themselves very well to the object-oriented paradigm because of them being , essentially, Sets. Stuff like activerecord is very well suited for modelling this data. For e.g. a blog - simply put class Post < ActiveRecord::Base has_many :comments end class Comment < ActiveRecord::Base belongs_to :post end How does one model this in Clojure - which is so strictly anti-OO ? Perhaps the question would have been better if it referred to all functional programming languages, but I am more interested from a Clojure standpoint (and Clojure examples)

    Read the article

  • How to create view model without sorting collections in memory.

    - by Chevex
    I have a view model (below). public class TopicsViewModel { public Topic Topic { get; set; } public Reply LastReply { get; set; } } I want to populate an IQueryable<TopicsViewModel> with values from my IQueryable<Topic> collection and IQueryable<Reply> collection. I do not want to use the attached entity collection (i.e. Topic.Replies) because I only want the last reply for that topic and doing Topic.Replies.Last() loads the entire entity collection in memory and then grabs the last one in the list. I am trying to stay in IQueryable so that the query is executed in the database. I also don't want to foreach through topics and query replyRepository.Replies because looping through IQueryable<Topic> will start the lazy loading. I'd prefer to build one expression and have all the leg work done in the lower layers. I have the following: IQueryable<TopicsViewModel> topicsViewModel = from x in topicRepository.Topics from y in replyRepository.Replies where y.TopicID == x.TopicID orderby y.PostedDate ascending select new TopicsViewModel { Topic = x, LastReply = y }; But this isn't working. Any ideas how I can populate an IQueryable or IEnumerable of TopicsViewModel so that it queries the database and grabs topics and that topic's last reply? I am trying really hard to avoid grabbing all replies related to that topic. I only want to grab the last reply. Thank you for any insight you have to offer.

    Read the article

  • Why represent shopping carts and order invoices differently in a domain model?

    - by Todd
    I've built some shopping cart systems in the past, but I always designed them such that the final order invoice is just a shopping cart that has been marked as "purchased". All the logic for adding/removing/changing items in a cart is also the logic for the order. All data is stored in the same tables in the database. But it seems this is not the proper way to design an e-commerce site.. Can someone explain the benefit of separating the shopping cart from invoices in the domain model? It seems to me this would lead to a lot of duplicated code, an extra set of tables in the database, and make it harder to maintain in the event the system need to start accommodating more complicated orders (like specifying selected options for an item which may or may not change the price/availability/shipping time of the order). I'm assuming I just haven't seen the light, as every book and other example I see seems to separate these two seemingly similar concerns -- but I can't find any explanation as to the benefit of doing such! It's also the case in the systems that I design that changes are often made after the initial order is confirmed. It's not uncommon for items to be removed, replaced, or added afterwards (but prior to fulfillment).

    Read the article

  • Does anyone still believe in the Capability Maturity Model for Software?

    - by Ed Guiness
    Ten years ago when I first encountered the CMM for software I was, I suppose like many, struck by how accurately it seemed to describe the chaotic "level one" state of software development in many businesses, particularly with its reference to reliance on heroes. It also seemed to provide realistic guidance for an organisation to progress up the levels improving their processes. But while it seemed to provide a good model and realistic guidance for improvement, I never really witnessed an adherence to CMM having a significant positive impact on any organisation I have worked for, or with. I know of one large software consultancy that claims CMM level 5 - the highest level - when I can see first hand that their processes are as chaotic, and the quality of their software products as varied, as other, non-CMM businesses. So I'm wondering, has anyone seen a real, tangible benefit from adherence to process improvement according to CMM? And if you have seen improvement, do you think that the improvement was specifically attributable to CMM, or would an alternative approach (such as six-sigma) have been equally or more beneficial? Does anyone still believe? As an aside, for those who haven't yet seen it, check out this funny-because-its-true parody

    Read the article

  • Where to translate message strings - in the view or in the model?

    - by GrGr
    We have a multilingual (PHP) application and use gettext for i18n. There are a few classes in the backend/model that return messages or message formats for printf(). We use xgettext to extract the strings that we want to translate. We apply the gettext function T_() in the frontend/view - this seems to be where it belongs. So far we kept the backend clean from T_() calls, this way we can also unit-test messages. So in the frontend we have something like echo T_($mymodel->getMessage()); or printf(T_($mymodel->getMessageFormat()), $mymodel->getValue()); This makes it impossible to apply xgettext to extract the strings, unless we put some dummy T_("my message %s to translate") call in the MyModel class. So this leads to the more general question: Do you apply translation in the backend classes, resp. where do you apply translation and how do you keep track of the strings which you have to translate? (I am aware of Question: poedit workaround for dynamic gettext.)

    Read the article

  • Do the 'up to date' guarantees provided by final field in Java's memory model extend to indirect ref

    - by mattbh
    The Java language spec defines semantics of final fields in section 17.5: The usage model for final fields is a simple one. Set the final fields for an object in that object's constructor. Do not write a reference to the object being constructed in a place where another thread can see it before the object's constructor is finished. If this is followed, then when the object is seen by another thread, that thread will always see the correctly constructed version of that object's final fields. It will also see versions of any object or array referenced by those final fields that are at least as up-to-date as the final fields are. My question is - does the 'up-to-date' guarantee extend to the contents of nested arrays, and nested objects? An example scenario: Thread A constructs a HashMap of ArrayLists, then assigns the HashMap to final field 'myFinal' in an instance of class 'MyClass' Thread B sees a (non-synchronized) reference to the MyClass instance and reads 'myFinal', and accesses and reads the contents of one of the ArrayLists In this scenario, are the members of the ArrayList as seen by Thread B guaranteed to be at least as up to date as they were when MyClass's constructor completed?

    Read the article

  • Rails nested attributes with a join model, where one of the models being joined is a new record

    - by gzuki
    I'm trying to build a grid, in rails, for entering data. It has rows and columns, and rows and columns are joined by cells. In my view, I need for the grid to be able to handle having 'new' rows and columns on the edge, so that if you type in them and then submit, they are automatically generated, and their shared cells are connected to them correctly. I want to be able to do this without JS. Rails nested attributes fail to handle being mapped to both a new record and a new column, they can only do one or the other. The reason is that they are a nested specifically in one of the two models, and whichever one they aren't nested in will have no id (since it doesn't exist yet), and when pushed through accepts_nested_attributes_for on the top level Grid model, they will only be bound to the new object created for whatever they were nested in. How can I handle this? Do I have to override rails handling of nested attributes? My models look like this, btw: class Grid < ActiveRecord::Base has_many :rows has_many :columns has_many :cells, :through => :rows accepts_nested_attributes_for :rows, :allow_destroy => true, :reject_if => lambda {|a| a[:description].blank? } accepts_nested_attributes_for :columns, :allow_destroy => true, :reject_if => lambda {|a| a[:description].blank? } end class Column < ActiveRecord::Base belongs_to :grid has_many :cells, :dependent => :destroy has_many :rows, :through => :grid end class Row < ActiveRecord::Base belongs_to :grid has_many :cells, :dependent => :destroy has_many :columns, :through => :grid accepts_nested_attributes_for :cells end class Cell < ActiveRecord::Base belongs_to :row belongs_to :column has_one :grid, :through => :row end

    Read the article

  • How can I add two models in one form, where one model is a has_many :through?

    - by Angela
    How do I model having multiple Addresses for a Company and assign a single Address to a Contact? Contacts belong_to a Company. A Company has_many Contacts. A Company also has_many Addresses. And each Contact has_one Address. I want to be able, whenever I create a New Contact, to access all the addresses in all Contacts that belong to the Company. Here is are my Models: class Company < ActiveRecord::Base attr_accessible :name, :phone, :addresses has_many :contacts has_many :addresses, :through => :contacts end class Contact < ActiveRecord::Base attr_accessible :first_name, :last_name, :title, :phone, :fax, :email, :company, :date_entered, :campaign_id, :company_name, :address belongs_to :company has_one :address accepts_nested_attributes_for :address end class Address < ActiveRecord::Base attr_accessible :street1 has_many :contacts end How do I create the View in the _form for Contacts so that I can 1) Add an Address when creating a Contact; 2) Display the options of the Address. Here is how I am doing step 1, which is just to add a new address for a new contact: <% f.fields_for :addresses do |builder| %> <p> <%= builder.label :street1, "Street 1" %> </br> <%= builder.text_field :street1 %> <p> Right now, what I have doesn't work. The console says I cannot mass-assign addresses when I hit "submit" on this New contact form.

    Read the article

  • Ruby on Rails How do I access variables of a model inside itself like in this example?

    - by banditKing
    I have a Model like so: # == Schema Information # # Table name: s3_files # # id :integer not null, primary key # owner :string(255) # notes :text # created_at :datetime not null # updated_at :datetime not null # last_accessed_by_user :string(255) # last_accessed_time_stamp :datetime # upload_file_name :string(255) # upload_content_type :string(255) # upload_file_size :integer # upload_updated_at :datetime # class S3File < ActiveRecord::Base #PaperClip methods attr_accessible :upload attr_accessor :owner Paperclip.interpolates :prefix do |attachment, style| I WOULD LIKE TO ACCESS VARIABLE= owner HERE- HOW TO DO THAT? end has_attached_file( :upload, :path => ":prefix/:basename.:extension", :storage => :s3, :s3_credentials => {:access_key_id => "ZXXX", :secret_access_key => "XXX"}, :bucket => "XXX" ) #Used to connect to users through the join table has_many :user_resource_relationships has_many :users, :through => :user_resource_relationships end Im setting this variable in the controller like so: # POST /s3_files # POST /s3_files.json def create @s3_file = S3File.new(params[:s3_file]) @s3_file.owner = current_user.email respond_to do |format| if @s3_file.save format.html { redirect_to @s3_file, notice: 'S3 file was successfully created.' } format.json { render json: @s3_file, status: :created, location: @s3_file } else format.html { render action: "new" } format.json { render json: @s3_file.errors, status: :unprocessable_entity } end end end Thanks, any help would be appreciated.

    Read the article

  • An Array returned by a model association is not an Array?

    - by Warren
    We have a model association that looks something like this: class Example < ActiveRecord::Base has_many :others, :order => 'others.rank' end The rank column is an integer type. The details of these particular models are not really important though as we have found the same problem with other has_many associations between other models. We have also added to the Enumerable module: module Enumerable def method_missing(name) super unless name.to_s[0..7] == 'collect_' method = name.to_s[8..-1] collect{|element| element.send(method)} end end This adds a collect_id method that we can use to get an array of record ids from an array of ActiveRecord objects. So if we use a normal ActiveRecord find :all, we get a nice array which we can then use collect_id on but if we use Example.others.collect_id, we get NoMethodError: undefined method `collect_id' for #<Class:0x2aaaac0060a0> Example.others.class returns "Array" so is it lying or confused? Our solution thus far has been to use it this way: Example.others.to_a.collect_id This works but this seems a bit strange. Why would you have to do that? We are on Ruby 1.8.7 and Rails 2.3.4

    Read the article

  • How can I find a laptop if it has a different model name all over the world?

    - by Mike
    CONUNDRUM: A laptop review in the UK talks about how brilliant the "ASUS ABCDE 55" is, but in America, France, etc there is no such laptop name. In fact it's called "ASUS 12345 AB" - AAARRGH! QUESTION: Is there a way of finding out all the diverse names for the same laptop all over the world? Example: if Samsung create a R2D2500, then what is that spec laptop called in all the other countries (if they release it of course). Or if it's not released, what is their similar spec laptop called in the other countries? I understand that specs may be different, but if I read a review on my trusted UK website, but live in say Australia, I want to be able to find the name of the same laptop in Australia and then check out local places to buy it. So if anyone knows if there is a technique, specific website, or even how to use a company website to find out these annoying name changes I'd really appreciate it.

    Read the article

  • Is there a CPU that can be described as "Celeron D 4xx model"?

    - by romkyns
    The "D" letter after Celeron appears to only be used for processors numbered with 3xx. Celerons of the 4xx series do not seem to have the "D". And yet I am looking at a motherboard described as supporting these processors: Intel Celeron D 3xx and 4xx models Intel Pentium 4 5xx and 6xx models Intel Pentium D 8xx and 9xx models Intel Core 2 Duo models with LGA775 Is this compatible with a Celeron 450, sSpec SLAFZ, despite not having a "D" in its name?

    Read the article

  • How does one dismantle the ThinkPad Mini Dock Series 3 (model 4337)?

    - by Whaa
    I have a ThinkPad Mini Dock Series 3 with a spring that is too stiff, causing problems with the connectivity when a computer is docked. I tried to open it so that I can soften the spring, but hit a brick wall. I removed all the screws I could find at the the bottom and the back panel of the docking station, but the bottom part of the plastic case would still not part from the top of the plastic case. I even looked under some of the various stickers for more screws, but found nothing. Can anyone please help with pointers on dismantling this docking station?

    Read the article

  • Query on MVVM pattern in WPF?

    - by Ashish Ashu
    I am implementing a MVVM pattern in my WPF application. My application main window is divided into four parts: Main Menu On the Top Outlook Navigation Control on the Left. A List View on the Middle. Another List view on the bottom. The Navigation control shows different setting (configuration) controls in the Tab items. All the four above are user controls which are placed in the main window. And corresponding to each user control there is separate view model which is bounded with a view model in the XAML of each control, however the model class remain the same between all the view model. And a MainWindow has a seperate View Model which is also bounded with a view model in the XAML of each control. Please help me out in framing a design in which each view models of all the controls above will interact with each other. Please let me know if my question is not clear to you!!

    Read the article

  • Dynamic attributes with Rails and Mongoid

    - by japancheese
    Hello, I'm learning MongoDB through the Mongoid Ruby gem with Rails (Rails 3 beta 3), and I'm trying to come up with a way to create dynamic attributes on a model based on fields from another model, which I thought a schema-less database would be a good choice for. So for example, I'd have the models: class Account include Mongoid::Document field :name, :type => String field :token, :type => String field :info_needed, :type => Array embeds_many :members end class Member include Mongoid::Document embedded_in :account, :inverse_of => :members end I'm looking to take the "info_needed" attribute of the Account model and created dynamic attributes on the Member model based on what's inside. If club.info_needed was ["first_name", "last_name"], I'm trying to create a form that would save first_name and last_name attributes to the Member model. However, upon practice, I just keep getting "undefined method first_name=" errors on the Member model when trying to do this. I know MongoDB can handle dynamic attributes per record, but how can I get Mongoid to do this without an undefined method error?

    Read the article

  • Simple ASP.Net MVC 1.0 Validation

    - by Mike
    On the current project we are working on we haven't upgraded to MVC 2.0 yet so I'm working on implementing some simple validation with the tools available in 1.0. I'm looking for feedback on the way I'm doing this. I have a model that represents a user profile. Inside that model I have a method that will validate all the fields and such. What I want to do is pass a controller to the validation method so that the model can set the model validation property in the controller. The goal is to get the validation from the controller into the model. Here is a quick example public FooController : Controller { public ActionResult Edit(User user) { user.ValidateModel(this); if (ModelState.IsValid) ....... ....... } } And my model validation signature is like public void ValidateModel(Controller currentState) What issues can you see with this? Am I way out to lunch on how I want to do this?

    Read the article

  • In Django, can you add a method to querysets?

    - by Paul D. Waite
    In Django, if I have a model class, e.g. from django.db import models class Transaction(models.Model): ... then if I want to add methods to the model, to store reasonably complex filters, I can add a custom model manager, e.g. class TransactionManager(models.Manager): def reasonable_complex_filter(self): return self.get_query_set().filter(...) class Transaction(models.Model): objects = TransactionManager() And then I can do: >>> Transaction.objects.reasonably_complex_filter() Is there any way I can add a custom method that can be chained to the end of a query set from the model? I.e. add the custom method in such a way that I can do this: >>> Transaction.objects.filter(...).reasonably_complex_filter()

    Read the article

  • Execute JavaScript function on a dynamic element (AJAX).

    - by jartaud
    Hello i have this following function: ... var model = $("#carModel"); .... model.change(validModel); function validModel(){ if(model.val() == undefined){ model.addClass("errorJS"); return false; }else{ model.removeClass("errorJS"); return true; } } I am getting carmodel id from a select box generated after an AJAX call. I can get its value in the Firebug console, but the function doest not execute. Even tough i use model.livequery(validModel); // The errorJS class put a red border in a element, if the function returns false

    Read the article

  • ASP.NET MVC 2.0 Unused Model Property being called when posting a product to the server?

    - by Erx_VB.NExT.Coder
    i have my auto-generated linq to sql classes, and i extend this class using partial classing (instead of using inheritance), and i have properties that that i've put in later which are not part of the database model and should not be. these are things like "FinalPrice" and "DisplayFinalPrice" - in the dbase, there is only RetailPrice and WholesalePrice so FinalPrice etc are more like extensions of the dbase fields. when i submit the form with nothing filled in, "FinalPrice" gets called (the 'get' of the property) even tho i never ask for it to be, and even tho it is not needed. this happens before validation, so i don't even get the validation errors i would get. i've tried using and on the FinalPrice and FinalPriceDisplay properties - no go! why does this happen and how can i stop it from happening? is the modelstate just trying to validate everything so therefore it calls every item no matter what? for those interested, here is all the code... Partial Public Class tProduct 'Inherits tProduct Private Const CommissionMultiplier As Decimal = CDec(1.18) Private _FinalPrice As Decimal? Private _DisplayFinalPrice As String Private _DisplayNormalPrice As String Public Property CategoryComplete As Short <ScaffoldColumn(False)> Public ReadOnly Property FinalPrice As Decimal Get 'If RetailPrice IsNot Nothing OrElse WholesalePrice IsNot Nothing Then If _FinalPrice Is Nothing Then If RetailPrice IsNot Nothing Then _FinalPrice = RetailPrice Else _FinalPrice = WholesalePrice * CommissionMultiplier ' TODO: this should be rounded to the nearest 5th cent so prices don't look weird. End If Dim NormalPart = Decimal.Floor(_FinalPrice.Value) Dim DecimalPart = _FinalPrice.Value - NormalPart If DecimalPart = 0 OrElse DecimalPart = 0.5 Then Return _FinalPrice ElseIf DecimalPart > 0 AndAlso DecimalPart < 0.5 Then DecimalPart = 0.5 ' always rounded up to the nearest 50 cents. ElseIf DecimalPart > 0.5 AndAlso DecimalPart < 1 Then ' Only in this case round down if its about to be rounded up to a valeu like 20, 30 or 50 etc as we want most prices to end in 9. If NormalPart.ToString.LastChr.ToInt = 9 Then DecimalPart = 0.5 Else DecimalPart = 1 End If End If _FinalPrice = NormalPart + DecimalPart End If Return _FinalPrice 'End If End Get End Property <ScaffoldColumn(False)> Public ReadOnly Property DisplayFinalPrice As String Get If _DisplayFinalPrice.IsNullOrEmpty Then _DisplayFinalPrice = FormatCurrency(FinalPrice, 2, TriState.True) End If Return _DisplayFinalPrice End Get End Property Public ReadOnly Property DisplayNormalPrice As String Get If _DisplayNormalPrice.IsNullOrEmpty Then _DisplayNormalPrice = FormatCurrency(NormalPrice, 2, TriState.True) End If Return _DisplayNormalPrice End Get End Property Public ReadOnly Property DivID As String Get Return "pdiv" & ProductID End Get End Property End Class more... i get busted here, with a null reference exception telling me it should contain a value... Dim NormalPart = Decimal.Floor(_FinalPrice.Value)

    Read the article

< Previous Page | 100 101 102 103 104 105 106 107 108 109 110 111  | Next Page >