search for: find_by_code

Displaying 10 results from an estimated 10 matches for "find_by_code".

2007 Dec 03
5
spec for model_id should eql
...ct'' FAILED expected 3, got nil (using .eql?) This spec that is failing: @address.department_id.should eql(3) before: before do @address = Address.new @address.attributes = valid_address_attributes @address.save @department = mock_model(Department) @department.stub!(:find_by_code).with("75").and_return("3") end The line of code I am writing the spec for: self.department = Department.find_by_code(self.postcode[0..1]) Many thanks, Omar -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspe...
2006 Feb 27
3
form questions
...t; <%= submit_tag ''Search'' %> <%= end_form_tag %> <%= link_to ''Back'', :action => ''list'' %> Here''s the method, search in the controller def search code=params[:message]["code"] @message = Message.find_by_code(code) if @message.nil? #render :action => ''find'' flash[:notice] = "Code #{code} not found!\n Please choose a code from this list" flash[:error] = ''Boom'' redirect_to :action => ''list'' else...
2006 Jan 11
15
How to use custom url formats?
I''m new to Rails and am trying to use a field called "code" instead of "id" in my URLs. For example, assuming I''ve got a database of motorcycles makes where the codes are "Honda", "Yamaha", "Suzuki", and "Kawasaki", etc. To show the info about Honda I want to use this url: http://www.mysite.com/makes/honda/
2006 Mar 23
8
DRY principle - how to implement?
Hi all! I have ''send_status'' table which looks something like these: id code title 1 sent Sent 2 error Sending error 3 success Success Next I would like to associate some processed records with their ''send_status''. Is it better to use: 1) record.status_id = SendStatus.find(:one, :condition => "code=''sent''").id to
2005 Dec 16
10
''Code table'' best practices?
I''ve been going back and forth about this kind of thing for a while. I reverse my opinion on it every project, and I''m wondering if anyone has any advice/battle scars to share. As usual, please forgive my long-windedness in advance. Let''s say I have this: Table: PLANS ID int CATEGORY_CODE_ID int --Other junk removed for clarity Table: CATEGORY_CODES ID int DESCRIPTION
2006 Feb 21
0
best practices for simple query
...<%= submit_tag ''Search'' %> <%= end_form_tag %> <%= link_to ''Back'', :action => ''list'' %> Here''s the method, search in the controller def search code=params[:message]["code"] @message = Message.find_by_code(code) if @message.nil? #render :action => ''find'' flash[:notice] = "Code #{code} not found!\n Please choose a code from this list" flash[:error] = ''Boom'' redirect_to :action => ''list'' else...
2006 Jan 12
1
Saving habtm relationships and Rails 1.0
I know there''s a problem saving has_and_belongs_to_many relationships w/ Rails 1.0 in that only the first association is saved (http://dev.rubyonrails.org/ticket/3213). What are people doing about this? I guess I could move to using the trunk release, but I''m hesitant because that might introduce a bunch of unknowns. Is there a workaround? For example, a way to explicitly
2005 Dec 12
0
Is this a good use for Single Table Inheritence?
...t Professor For the discrepencies, there would be an additional column pointing to the code it really is. id: 2 code: ASO description: <blank> parent: 1 (A better name for this would be great, but you ge the idea.) So, what would be the best way to apply a code to someone? Write a custom find_by_code that returns the code if it has no parent and the parent code if it does? Thanks! Sean
2007 Apr 03
0
[Sybase Adaptor] find_by_xxx does not work correctly.
...rst_name,:string >> User.find(1) => #<User:0x2abe232a68e8 @attributes={"code"=>"1", "id"=>"1", "first_name"=>"hiroyuki", "last_name"=>"sato"}> code data only include number >> User.find_by_code("1") ActiveRecord::StatementInvalid: RuntimeError: SQL Command Failed for User Load: SELECT * FROM users WHERE (users.[code] = 1) This SQL should be quote like this SELECT * FROM users WHERE (users.[code] = "1") * probelm source sybase_adapter.rb 279 def quote(valu...
2006 Feb 04
4
AJAX rendered select doesn''t get submitted
...ltered_state_select}, :with => "''country_code='' + value") %> _______________________________________________________________________________ StateController#filtered_state_select def filtered_state_select #ajax action country = Country.find_by_code(@params["country_code"]) @state_groups = StateGroup.find_all_by_country_id(country.id) @state_groups.each {|g| g.name = ''- '' + g.name + '' -''} render(:partial => ''options'') end __________________________________...