Currently have two models Pay and Wage Pay has 2 columns (methods) id and name Wage has 3 columns id, pay_id and name Pay is set up with: has_many :wages Wage is: belongs_to :pay First, I believe this is set up correctly , according to Rails idiom. There are many wages that can be associate with a pay. However in trying to map wage to pay I''m having a problem with this line: (This is an example line:) <%= select ''model'',''category_id'', Model.find(@model.id).categories.map {|x| [x.name, x.id]} %> The use of ''category_id'' and ''categories'' I think is throwing me off. How does category relate to my wage model ? TIA Stuart --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Maybe I should provide some additonal explanation in what I''m trying to accomplish. This is using the KRJS plugin. In the example: # View <%= select ''model'',''id'' %> <div id=''select-b''> <%= select ''model'',''category_id'', Model.find(@model.id).categories.map {|x| [x.name, x.id]} %> </div> #controller: def on_model_id_change render :update do |page| @categories = Model.find(params[:dom_value]).categories page.replace_html ''select-b'', :inline=>"<%= select ''model'',''category_id'', @categories.map {|o| [o.name, o.id]} %>" end end The thing that is throwing me here is the use of category_id and categories. Stuart On 9/8/06, Dark Ambient <sambient-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Currently have two models > Pay and Wage > > Pay has 2 columns (methods) id and name > Wage has 3 columns id, pay_id and name > > Pay is set up with: > has_many :wages > > Wage is: > belongs_to :pay > > First, I believe this is set up correctly , according to Rails idiom. > There are many wages that can be associate with a pay. > > However in trying to map wage to pay I''m having a problem with this line: > (This is an example line:) > <%= select ''model'',''category_id'', Model.find(@model.id).categories.map > {|x| [x.name, x.id]} %> > The use of ''category_id'' and ''categories'' I think is throwing me off. > How does category relate to my wage model ? > > TIA > Stuart >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Where does Model and it''s related categories field come from? Jason On 9/8/06, Dark Ambient <sambient-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > Maybe I should provide some additonal explanation in what I''m trying > to accomplish. This is using the KRJS plugin. > > In the example: > # View > <%= select ''model'',''id'' %> > <div id=''select-b''> > <%= select ''model'',''category_id'', Model.find(@model.id).categories.map > {|x| [x.name, x.id]} %> > </div> > > #controller: > def on_model_id_change > render :update do |page| > @categories = Model.find(params[:dom_value]).categories > page.replace_html ''select-b'', :inline=>"<%= select > ''model'',''category_id'', @categories.map {|o| > [o.name, o.id]} %>" > end > end > > The thing that is throwing me here is the use of category_id and > categories. > > Stuart > > > > > > > On 9/8/06, Dark Ambient <sambient-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Currently have two models > > Pay and Wage > > > > Pay has 2 columns (methods) id and name > > Wage has 3 columns id, pay_id and name > > > > Pay is set up with: > > has_many :wages > > > > Wage is: > > belongs_to :pay > > > > First, I believe this is set up correctly , according to Rails idiom. > > There are many wages that can be associate with a pay. > > > > However in trying to map wage to pay I''m having a problem with this > line: > > (This is an example line:) > > <%= select ''model'',''category_id'', Model.find(@model.id).categories.map > > {|x| [x.name, x.id]} %> > > The use of ''category_id'' and ''categories'' I think is throwing me off. > > How does category relate to my wage model ? > > > > TIA > > Stuart > > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Model in the example is just a holder for the model name I believe. Categories in my model doesn''t exist. so maybe my associations are wrong. In my thinking the pay.id in Pay relates to the pay_id in the Wages table. Yet I keep coming up with nil errors. Stuart On 9/8/06, Jason Roelofs <jameskilton-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Where does Model and it''s related categories field come from? > > Jason > > > On 9/8/06, Dark Ambient <sambient-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > wrote: > > > > Maybe I should provide some additonal explanation in what I''m trying > > to accomplish. This is using the KRJS plugin. > > > > In the example: > > # View > > <%= select ''model'',''id'' %> > > <div id=''select-b''> > > <%= select ''model'',''category_id'', Model.find(@ model.id).categories.map > > {|x| [x.name, x.id]} %> > > </div> > > > > #controller: > > def on_model_id_change > > render :update do |page| > > @categories = Model.find(params[:dom_value]).categories > > page.replace_html ''select-b'', :inline=>"<%= select > > ''model'',''category_id'', > @categories.map {|o| > > [o.name , o.id]} %>" > > end > > end > > > > The thing that is throwing me here is the use of category_id and > categories. > > > > Stuart > > > > > > > > > > > > > > On 9/8/06, Dark Ambient < sambient-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Currently have two models > > > Pay and Wage > > > > > > Pay has 2 columns (methods) id and name > > > Wage has 3 columns id, pay_id and name > > > > > > Pay is set up with: > > > has_many :wages > > > > > > Wage is: > > > belongs_to :pay > > > > > > First, I believe this is set up correctly , according to Rails idiom. > > > There are many wages that can be associate with a pay. > > > > > > However in trying to map wage to pay I''m having a problem with this > line: > > > (This is an example line:) > > > <%= select ''model'',''category_id'', Model.find(@model.id ).categories.map > > > {|x| [x.name, x.id]} %> > > > The use of ''category_id'' and ''categories'' I think is throwing me off. > > > How does category relate to my wage model ? > > > > > > TIA > > > Stuart > > > > > > > > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Your associations and assumptions between Pay and Wage are correct from what you originally posted. Can you post the actual RHTML code that is suspect here? I''m having a hard time understanding the situation here. Jason On 9/8/06, Dark Ambient <sambient-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > Model in the example is just a holder for the model name I believe. > Categories in my model doesn''t exist. > so maybe my associations are wrong. > > In my thinking the pay.id in Pay relates to the pay_id in the Wages > table. > Yet I keep coming up with nil errors.Stuart> > > > On 9/8/06, Jason Roelofs <jameskilton-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Where does Model and it''s related categories field come from? > > > > Jason > > > > > > On 9/8/06, Dark Ambient <sambient-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > wrote: > > > > > > Maybe I should provide some additonal explanation in what I''m trying > > > to accomplish. This is using the KRJS plugin. > > > > > > In the example: > > > # View > > > <%= select ''model'',''id'' %> > > > <div id=''select-b''> > > > <%= select ''model'',''category_id'', Model.find(@ model.id > ).categories.map > > > {|x| [x.name, x.id]} %> > > > </div> > > > > > > #controller: > > > def on_model_id_change > > > render :update do |page| > > > @categories = Model.find(params[:dom_value]).categories > > > page.replace_html ''select-b'', :inline=>"<%= select > > > ''model'',''category_id'', > > @categories.map {|o| > > > [o.name , o.id]} %>" > > > end > > > end > > > > > > The thing that is throwing me here is the use of category_id and > > categories. > > > > > > Stuart > > > > > > > > > > > > > > > > > > > > > On 9/8/06, Dark Ambient < sambient-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Currently have two models > > > > Pay and Wage > > > > > > > > Pay has 2 columns (methods) id and name > > > > Wage has 3 columns id, pay_id and name > > > > > > > > Pay is set up with: > > > > has_many :wages > > > > > > > > Wage is: > > > > belongs_to :pay > > > > > > > > First, I believe this is set up correctly , according to Rails > idiom. > > > > There are many wages that can be associate with a pay. > > > > > > > > However in trying to map wage to pay I''m having a problem with this > > line: > > > > (This is an example line:) > > > > <%= select ''model'',''category_id'', Model.find(@model.id).categories.map > > > > {|x| [x.name, x.id]} %> > > > > The use of ''category_id'' and ''categories'' I think is throwing me > off. > > > > How does category relate to my wage model ? > > > > > > > > TIA > > > > Stuart > > > > > > > > > > > > > > > > > > > > > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
I''m just going to start this all over - cause I live on the ground floor so jumping isn''t going to help. I''ve also looked at it every which way and Sunday with no luck. I''m looking at this linkhttp://www.sciwerks.com/blog/2006/07/07/updating-select-controls-with-ajax/ where it is talking about KRJS plugin. Regardless my particular question is not related to the plugin ...yet. The page is talking about updating a second select box based on the choice user makes in first. It goes on to show an example view: # View <%= select ''model'',''id'' %> <div id=''select-b''> <%= select ''model'',''category_id'', Model.find(@model.id).categories.map {|x| [x.name, x.id]} %> </div> So in the example it''s clear that the 2nd select contains a column that is tied into the first select , category. So taking my two models Pay and Wage - where Wage contains a method pay_id I continue to get nil errors in the place @model.id) Stuart --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
<%= select ''pay'', ''id'', Pay.find(:all).collect {|p| [p.name, p.id]}%> <div id=''select-b''> <%= select ''wage'',''pay_id'', @pay.wages.map {|x| [x.name, x.id]} %> </div> You have a nil object when you didn''t expect it! The error occured while evaluating nil.wages Stuart On 9/8/06, Jason Roelofs <jameskilton-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Your associations and assumptions between Pay and Wage are correct from what > you originally posted. Can you post the actual RHTML code that is suspect > here? I''m having a hard time understanding the situation here. > > > Jason > > On 9/8/06, Dark Ambient <sambient-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Model in the example is just a holder for the model name I believe. > > Categories in my model doesn''t exist. > > so maybe my associations are wrong. > > > > In my thinking the pay.id in Pay relates to the pay_id in the Wages > table. > > Yet I keep coming up with nil errors. > > > Stuart > > > > > > > > On 9/8/06, Jason Roelofs <jameskilton-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Where does Model and it''s related categories field come from? > > > > > > Jason > > > > > > > > > On 9/8/06, Dark Ambient < sambient-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > wrote: > > > > > > > > Maybe I should provide some additonal explanation in what I''m trying > > > > to accomplish. This is using the KRJS plugin. > > > > > > > > In the example: > > > > # View > > > > <%= select ''model'',''id'' %> > > > > <div id=''select-b''> > > > > <%= select ''model'',''category_id'', Model.find(@ > model.id).categories.map > > > > {|x| [x.name, x.id]} %> > > > > </div> > > > > > > > > #controller: > > > > def on_model_id_change > > > > render :update do |page| > > > > @categories = Model.find(params[:dom_value]).categories > > > > page.replace_html ''select-b'', :inline=>"<%= select > > > > ''model'',''category_id'', > > > @categories.map {|o| > > > > [o.name , o.id]} %>" > > > > end > > > > end > > > > > > > > The thing that is throwing me here is the use of category_id and > > > categories. > > > > > > > > Stuart > > > > > > > > > > > > > > > > > > > > > > > > > > > > On 9/8/06, Dark Ambient < sambient-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > wrote: > > > > > Currently have two models > > > > > Pay and Wage > > > > > > > > > > Pay has 2 columns (methods) id and name > > > > > Wage has 3 columns id, pay_id and name > > > > > > > > > > Pay is set up with: > > > > > has_many :wages > > > > > > > > > > Wage is: > > > > > belongs_to :pay > > > > > > > > > > First, I believe this is set up correctly , according to Rails > idiom. > > > > > There are many wages that can be associate with a pay. > > > > > > > > > > However in trying to map wage to pay I''m having a problem with this > > > line: > > > > > (This is an example line:) > > > > > <%= select ''model'',''category_id'', Model.find(@model.id > ).categories.map > > > > > {|x| [x.name, x.id]} %> > > > > > The use of ''category_id'' and ''categories'' I think is throwing me > off. > > > > > How does category relate to my wage model ? > > > > > > > > > > TIA > > > > > Stuart > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Well, do you ever set @pay in your controller? Jason On 9/8/06, Dark Ambient <sambient-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > I''m just going to start this all over - cause I live on the ground > floor so jumping isn''t going to help. I''ve also looked at it every > which way and Sunday with no luck. > I''m looking at this > > linkhttp://www.sciwerks.com/blog/2006/07/07/updating-select-controls-with-ajax/ > where it is talking about KRJS plugin. Regardless my particular > question is not related to the plugin ...yet. > > The page is talking about updating a second select box based on the > choice user makes in first. It goes on to show an example view: > # View > <%= select ''model'',''id'' %> > <div id=''select-b''> > <%= select ''model'',''category_id'', Model.find(@model.id).categories.map > {|x| [x.name, x.id]} %> > </div> > > So in the example it''s clear that the 2nd select contains a column > that is tied into the first select , category. > > So taking my two models Pay and Wage - where Wage contains a method > pay_id I continue to get nil errors in the place @model.id) > > Stuart > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---