I think I am going blind, because I cannot find what is wrong with the following. The bad thing is that I had it working, made couple of changes, reverted back to the original, now it doesn''t work. I have been trying to figure out why this isn''t working way too long, to the point my vision is blurring. <div style="border:3px solid #999"> <% form_for :categories, :url => {:action => "show_tasks"} do |form| %> Select Category: <%= form.collection_select :name, @categories, :id, :name %> <%= submit_tag "View" %> <% end %> </div> here is the error message NoMethodError in Mytasks#index Showing app/views/mytasks/index.rhtml where line #10 raised: undefined method `name'' for #<Array:0xb7611edc> Extracted source (around line #10): 7: <div style="border:3px solid #999"> 8: <% form_for :categories, :url => {:action => "show_tasks"} do | form| %> 9: Select Category: 10: <%= form.collection_select :name, @categories, :id, :name %> 11: <%= submit_tag "View" %> 12: <% end %> 13: </div> Thanks for the help --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
On 8-Apr-07, at 4:58 PM, chris wrote:> > I think I am going blind, because I cannot find what is wrong with the > following. The bad thing is that I had it working, made couple of > changes, reverted back to the original, now it doesn''t work. > > I have been trying to figure out why this isn''t working way too long, > to the point my vision is blurring. > > <div style="border:3px solid #999"> > <% form_for :categories, :url => {:action => "show_tasks"} do |form| > %> > Select Category: > <%= form.collection_select :name, @categories, :id, :name %> > <%= submit_tag "View" %> > <% end %> > </div> > > here is the error message > > NoMethodError in Mytasks#index > Showing app/views/mytasks/index.rhtml where line #10 raised: > undefined method `name'' for #<Array:0xb7611edc> > > Extracted source (around line #10): > > 7: <div style="border:3px solid #999"> > 8: <% form_for :categories, :url => {:action => "show_tasks"} do | > form| %> > 9: Select Category: > 10: <%= form.collection_select :name, @categories, :id, :name %> > 11: <%= submit_tag "View" %> > 12: <% end %> > 13: </div>Chris, @categories is your problem. collection_select is iterating through @categories looking for category.name. Take a look at your controller where you''re populating @categories. Cheers, Jodi General Partner The nNovation Group inc. www.nnovation.ca/blog --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
Sorry, I should''ve mentioned that there has been no changes to the controller since I had it working. Here is the index method from the controller def index @categories = Category.find(:all) @tasks = [] end But the error is in regards to to the *select control. If I remove line 10 from the index.rhtml file it renders to the browser without any errors. On Apr 8, 3:11 pm, Jodi Showers <j...-BOB1p6JRLoAV+D8aMU/kSg@public.gmane.org> wrote:> On 8-Apr-07, at 4:58 PM, chris wrote: > > > > > > > I think I am going blind, because I cannot find what is wrong with the > > following. The bad thing is that I had it working, made couple of > > changes, reverted back to the original, now it doesn''t work. > > > I have been trying to figure out why this isn''t working way too long, > > to the point my vision is blurring. > > > <div style="border:3px solid #999"> > > <% form_for :categories, :url => {:action => "show_tasks"} do |form| > > %> > > Select Category: > > <%= form.collection_select :name, @categories, :id, :name %> > > <%= submit_tag "View" %> > > <% end %> > > </div> > > > here is the error message > > > NoMethodError in Mytasks#index > > Showing app/views/mytasks/index.rhtml where line #10 raised: > > undefined method `name'' for #<Array:0xb7611edc> > > > Extracted source (around line #10): > > > 7: <div style="border:3px solid #999"> > > 8: <% form_for :categories, :url => {:action => "show_tasks"} do | > > form| %> > > 9: Select Category: > > 10: <%= form.collection_select :name, @categories, :id, :name %> > > 11: <%= submit_tag "View" %> > > 12: <% end %> > > 13: </div> > > Chris, @categories is your problem. > > collection_select is iterating through @categories looking for > category.name. > > Take a look at your controller where you''re populating @categories. > > Cheers, > Jodi > General Partner > The nNovation Group inc.www.nnovation.ca/blog > > on-innovation.gif > 11KViewDownload > >--~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Chris, you should be able to do the following: <%= form.collection_select ''task'', ''category_id'', @categories, ''id'', ''<some_category_attribute>'' %> This invocation will generate a select tag name="task[category_id]" with options of form <option value="category.id">category.<some_category_attribute></option>. The option with category.id == user.category_id will be selected. Now, I''m guessing the following from you previous e-mail: task belongs_to category category has_many tasks Thus, I''m seeing the following relationship: class Task < ActiveRecord::Base belongs_to :category end class Category < ActiveRecord::Base has_many :tasks end Please note that Task model contains the foreign key, ''category_id'', because it has the belongs_to declaration. Good luck, -Conrad On 4/8/07, chris <olsen.chris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Sorry, I should''ve mentioned that there has been no changes to the > controller since I had it working. > Here is the index method from the controller > > def index > @categories = Category.find(:all) > @tasks = [] > end > > But the error is in regards to to the *select control. If I remove > line 10 from the index.rhtml file it renders to the browser without > any errors. > > > On Apr 8, 3:11 pm, Jodi Showers <j...-BOB1p6JRLoAV+D8aMU/kSg@public.gmane.org> wrote: > > On 8-Apr-07, at 4:58 PM, chris wrote: > > > > > > > > > > > > > I think I am going blind, because I cannot find what is wrong with the > > > following. The bad thing is that I had it working, made couple of > > > changes, reverted back to the original, now it doesn''t work. > > > > > I have been trying to figure out why this isn''t working way too long, > > > to the point my vision is blurring. > > > > > <div style="border:3px solid #999"> > > > <% form_for :categories, :url => {:action => "show_tasks"} do |form| > > > %> > > > Select Category: > > > <%= form.collection_select :name, @categories, :id, :name %> > > > <%= submit_tag "View" %> > > > <% end %> > > > </div> > > > > > here is the error message > > > > > NoMethodError in Mytasks#index > > > Showing app/views/mytasks/index.rhtml where line #10 raised: > > > undefined method `name'' for #<Array:0xb7611edc> > > > > > Extracted source (around line #10): > > > > > 7: <div style="border:3px solid #999"> > > > 8: <% form_for :categories, :url => {:action => "show_tasks"} do | > > > form| %> > > > 9: Select Category: > > > 10: <%= form.collection_select :name, @categories, :id, :name %> > > > 11: <%= submit_tag "View" %> > > > 12: <% end %> > > > 13: </div> > > > > Chris, @categories is your problem. > > > > collection_select is iterating through @categories looking for > > category.name. > > > > Take a look at your controller where you''re populating @categories. > > > > Cheers, > > Jodi > > General Partner > > The nNovation Group inc.www.nnovation.ca/blog > > > > on-innovation.gif > > 11KViewDownload > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
Since I am just playing around with things I am constantly re- formatting how things are arranged on the screen. How this is supposed to work, is that at the top of the screen there is a select list containing the categories, that combined within the button beside it, allows the user to easily view the todo''s for each of the categories. So the select control that I am having problems with isn''t yet, at the time of the problem, related to the tasks just yet. I want to fill the select control with all the categories that exist in the database. Thanks for the help, I really appreciate it. On Apr 8, 5:23 pm, "Conrad Taylor" <conra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi Chris, you should be able to do the following: > > <%= form.collection_select ''task'', ''category_id'', @categories, ''id'', > ''<some_category_attribute>'' %> > > This invocation will generate a select tag name="task[category_id]" with > options of form <option > value="category.id">category.<some_category_attribute></option>. The > option with category.id == user.category_id will be selected. > > Now, I''m guessing the following from you previous e-mail: > > task belongs_to category > category has_many tasks > > Thus, I''m seeing the following relationship: > > class Task < ActiveRecord::Base > belongs_to :category > end > > class Category < ActiveRecord::Base > has_many :tasks > end > > Please note that Task model contains the foreign key, ''category_id'', > because it has the belongs_to declaration. > > Good luck, > > -Conrad > > On 4/8/07, chris <olsen.ch...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Sorry, I should''ve mentioned that there has been no changes to the > > controller since I had it working. > > Here is the index method from the controller > > > def index > > @categories = Category.find(:all) > > @tasks = [] > > end > > > But the error is in regards to to the *select control. If I remove > > line 10 from the index.rhtml file it renders to the browser without > > any errors. > > > On Apr 8, 3:11 pm, Jodi Showers <j...-BOB1p6JRLoAV+D8aMU/kSg@public.gmane.org> wrote: > > > On 8-Apr-07, at 4:58 PM, chris wrote: > > > > > I think I am going blind, because I cannot find what is wrong with the > > > > following. The bad thing is that I had it working, made couple of > > > > changes, reverted back to the original, now it doesn''t work. > > > > > I have been trying to figure out why this isn''t working way too long, > > > > to the point my vision is blurring. > > > > > <div style="border:3px solid #999"> > > > > <% form_for :categories, :url => {:action => "show_tasks"} do |form| > > > > %> > > > > Select Category: > > > > <%= form.collection_select :name, @categories, :id, :name %> > > > > <%= submit_tag "View" %> > > > > <% end %> > > > > </div> > > > > > here is the error message > > > > > NoMethodError in Mytasks#index > > > > Showing app/views/mytasks/index.rhtml where line #10 raised: > > > > undefined method `name'' for #<Array:0xb7611edc> > > > > > Extracted source (around line #10): > > > > > 7: <div style="border:3px solid #999"> > > > > 8: <% form_for :categories, :url => {:action => "show_tasks"} do | > > > > form| %> > > > > 9: Select Category: > > > > 10: <%= form.collection_select :name, @categories, :id, :name %> > > > > 11: <%= submit_tag "View" %> > > > > 12: <% end %> > > > > 13: </div> > > > > Chris, @categories is your problem. > > > > collection_select is iterating through @categories looking for > > > category.name. > > > > Take a look at your controller where you''re populating @categories. > > > > Cheers, > > > Jodi > > > General Partner > > > The nNovation Group inc.www.nnovation.ca/blog > > > > on-innovation.gif > > > 11KViewDownload--~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
maybe this will help. I totally removed the linkage to the categories and tried to hard code some values, with some random names <div style="border:3px solid #999"> <% form_for :categories, :url => {:action => "show_tasks"} do |form| %> Select Category: <%= form.select "some_names", %w{Chris, Andy, Wally} %> <%= submit_tag "View" %> <% end %> </div> Here is the error message ================== NoMethodError in Mytasks#index Showing app/views/mytasks/index.rhtml where line #10 raised: undefined method `some_names'' for #<Array:0xb757f654> Extracted source (around line #10): 7: <div style="border:3px solid #999"> 8: <% form_for :categories, :url => {:action => "show_tasks"} do | form| %> 9: Select Category: 10: <%= form.select "some_names", %w{Chris, Andy, Wally} %> 11: <%= submit_tag "View" %> 12: <% end %> 13: </div> On Apr 8, 6:18 pm, "chris" <olsen.ch...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Since I am just playing around with things I am constantly re- > formatting how things are arranged on the screen. How this is > supposed to work, is that at the top of the screen there is a select > list containing the categories, that combined within the button beside > it, allows the user to easily view the todo''s for each of the > categories. > > So the select control that I am having problems with isn''t yet, at the > time of the problem, related to the tasks just yet. I want to fill > the select control with all the categories that exist in the database. > > Thanks for the help, I really appreciate it. > > On Apr 8, 5:23 pm, "Conrad Taylor" <conra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi Chris, you should be able to do the following: > > > <%= form.collection_select ''task'', ''category_id'', @categories, ''id'', > > ''<some_category_attribute>'' %> > > > This invocation will generate a select tag name="task[category_id]" with > > options of form <option > > value="category.id">category.<some_category_attribute></option>. The > > option with category.id == user.category_id will be selected. > > > Now, I''m guessing the following from you previous e-mail: > > > task belongs_to category > > category has_many tasks > > > Thus, I''m seeing the following relationship: > > > class Task < ActiveRecord::Base > > belongs_to :category > > end > > > class Category < ActiveRecord::Base > > has_many :tasks > > end > > > Please note that Task model contains the foreign key, ''category_id'', > > because it has the belongs_to declaration. > > > Good luck, > > > -Conrad > > > On 4/8/07, chris <olsen.ch...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Sorry, I should''ve mentioned that there has been no changes to the > > > controller since I had it working. > > > Here is the index method from the controller > > > > def index > > > @categories = Category.find(:all) > > > @tasks = [] > > > end > > > > But the error is in regards to to the *select control. If I remove > > > line 10 from the index.rhtml file it renders to the browser without > > > any errors. > > > > On Apr 8, 3:11 pm, Jodi Showers <j...-BOB1p6JRLoAV+D8aMU/kSg@public.gmane.org> wrote: > > > > On 8-Apr-07, at 4:58 PM, chris wrote: > > > > > > I think I am going blind, because I cannot find what is wrong with the > > > > > following. The bad thing is that I had it working, made couple of > > > > > changes, reverted back to the original, now it doesn''t work. > > > > > > I have been trying to figure out why this isn''t working way too long, > > > > > to the point my vision is blurring. > > > > > > <div style="border:3px solid #999"> > > > > > <% form_for :categories, :url => {:action => "show_tasks"} do |form| > > > > > %> > > > > > Select Category: > > > > > <%= form.collection_select :name, @categories, :id, :name %> > > > > > <%= submit_tag "View" %> > > > > > <% end %> > > > > > </div> > > > > > > here is the error message > > > > > > NoMethodError in Mytasks#index > > > > > Showing app/views/mytasks/index.rhtml where line #10 raised: > > > > > undefined method `name'' for #<Array:0xb7611edc> > > > > > > Extracted source (around line #10): > > > > > > 7: <div style="border:3px solid #999"> > > > > > 8: <% form_for :categories, :url => {:action => "show_tasks"} do | > > > > > form| %> > > > > > 9: Select Category: > > > > > 10: <%= form.collection_select :name, @categories, :id, :name %> > > > > > 11: <%= submit_tag "View" %> > > > > > 12: <% end %> > > > > > 13: </div> > > > > > Chris, @categories is your problem. > > > > > collection_select is iterating through @categories looking for > > > > category.name. > > > > > Take a look at your controller where you''re populating @categories. > > > > > Cheers, > > > > Jodi > > > > General Partner > > > > The nNovation Group inc.www.nnovation.ca/blog > > > > > on-innovation.gif > > > > 11KViewDownload--~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
Hi, you should be able to do the following: 1) Define this in the relevant model. category_type = [ [ "Chris", "1" ] [ "Andy", "2" ] [ "Wally", "3" ] ] 2) Add this code to the relevant view. <%= form.select :some_names, <class_name>::category_type %> Note: <class_name> := The name of your model class. For example, Category Good luck, -Conrad On 4/8/07, chris <olsen.chris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > maybe this will help. I totally removed the linkage to the categories > and tried to hard code some values, with some random names > > <div style="border:3px solid #999"> > <% form_for :categories, :url => {:action => "show_tasks"} do |form| > %> > Select Category: > <%= form.select "some_names", %w{Chris, Andy, Wally} %> > <%= submit_tag "View" %> > <% end %> > </div> > > Here is the error message > ==================> NoMethodError in Mytasks#index > Showing app/views/mytasks/index.rhtml where line #10 raised: > undefined method `some_names'' for #<Array:0xb757f654> > > Extracted source (around line #10): > > 7: <div style="border:3px solid #999"> > 8: <% form_for :categories, :url => {:action => "show_tasks"} do | > form| %> > 9: Select Category: > 10: <%= form.select "some_names", %w{Chris, Andy, Wally} %> > 11: <%= submit_tag "View" %> > 12: <% end %> > 13: </div> > > > > > > On Apr 8, 6:18 pm, "chris" <olsen.ch...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Since I am just playing around with things I am constantly re- > > formatting how things are arranged on the screen. How this is > > supposed to work, is that at the top of the screen there is a select > > list containing the categories, that combined within the button beside > > it, allows the user to easily view the todo''s for each of the > > categories. > > > > So the select control that I am having problems with isn''t yet, at the > > time of the problem, related to the tasks just yet. I want to fill > > the select control with all the categories that exist in the database. > > > > Thanks for the help, I really appreciate it. > > > > On Apr 8, 5:23 pm, "Conrad Taylor" <conra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Hi Chris, you should be able to do the following: > > > > > <%= form.collection_select ''task'', ''category_id'', @categories, ''id'', > > > ''<some_category_attribute>'' %> > > > > > This invocation will generate a select tag name="task[category_id]" with > > > options of form <option > > > value="category.id">category.<some_category_attribute></option>. The > > > option with category.id == user.category_id will be selected. > > > > > Now, I''m guessing the following from you previous e-mail: > > > > > task belongs_to category > > > category has_many tasks > > > > > Thus, I''m seeing the following relationship: > > > > > class Task < ActiveRecord::Base > > > belongs_to :category > > > end > > > > > class Category < ActiveRecord::Base > > > has_many :tasks > > > end > > > > > Please note that Task model contains the foreign key, ''category_id'', > > > because it has the belongs_to declaration. > > > > > Good luck, > > > > > -Conrad > > > > > On 4/8/07, chris <olsen.ch...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > Sorry, I should''ve mentioned that there has been no changes to the > > > > controller since I had it working. > > > > Here is the index method from the controller > > > > > > def index > > > > @categories = Category.find(:all) > > > > @tasks = [] > > > > end > > > > > > But the error is in regards to to the *select control. If I remove > > > > line 10 from the index.rhtml file it renders to the browser without > > > > any errors. > > > > > > On Apr 8, 3:11 pm, Jodi Showers <j...-BOB1p6JRLoAV+D8aMU/kSg@public.gmane.org> wrote: > > > > > On 8-Apr-07, at 4:58 PM, chris wrote: > > > > > > > > I think I am going blind, because I cannot find what is wrong with the > > > > > > following. The bad thing is that I had it working, made couple of > > > > > > changes, reverted back to the original, now it doesn''t work. > > > > > > > > I have been trying to figure out why this isn''t working way too long, > > > > > > to the point my vision is blurring. > > > > > > > > <div style="border:3px solid #999"> > > > > > > <% form_for :categories, :url => {:action => "show_tasks"} do |form| > > > > > > %> > > > > > > Select Category: > > > > > > <%= form.collection_select :name, @categories, :id, :name %> > > > > > > <%= submit_tag "View" %> > > > > > > <% end %> > > > > > > </div> > > > > > > > > here is the error message > > > > > > > > NoMethodError in Mytasks#index > > > > > > Showing app/views/mytasks/index.rhtml where line #10 raised: > > > > > > undefined method `name'' for #<Array:0xb7611edc> > > > > > > > > Extracted source (around line #10): > > > > > > > > 7: <div style="border:3px solid #999"> > > > > > > 8: <% form_for :categories, :url => {:action => "show_tasks"} do | > > > > > > form| %> > > > > > > 9: Select Category: > > > > > > 10: <%= form.collection_select :name, @categories, :id, :name %> > > > > > > 11: <%= submit_tag "View" %> > > > > > > 12: <% end %> > > > > > > 13: </div> > > > > > > > Chris, @categories is your problem. > > > > > > > collection_select is iterating through @categories looking for > > > > > category.name. > > > > > > > Take a look at your controller where you''re populating @categories. > > > > > > > Cheers, > > > > > Jodi > > > > > General Partner > > > > > The nNovation Group inc.www.nnovation.ca/blog > > > > > > > on-innovation.gif > > > > > 11KViewDownload > > > > >--~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
Hi, here''s the corrected version: category_type = [ [ "Chris", "1" ], [ "Andy", "2" ], [ "Wally", "3" ] ] On 4/8/07, Conrad Taylor <conradwt-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, you should be able to do the following: > > 1) Define this in the relevant model. > > category_type = [ > [ "Chris", "1" ] > [ "Andy", "2" ] > [ "Wally", "3" ] > ] > > 2) Add this code to the relevant view. > > <%= form.select :some_names, <class_name>::category_type %> > > Note: <class_name> := The name of your model class. For example, > > Category > > Good luck, > > -Conrad > > On 4/8/07, chris <olsen.chris-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > maybe this will help. I totally removed the linkage to the categories > > and tried to hard code some values, with some random names > > > > <div style="border:3px solid #999"> > > <% form_for :categories, :url => {:action => "show_tasks"} do |form| > > %> > > Select Category: > > <%= form.select "some_names", %w{Chris, Andy, Wally} %> > > <%= submit_tag "View" %> > > <% end %> > > </div> > > > > Here is the error message > > ==================> > NoMethodError in Mytasks#index > > Showing app/views/mytasks/index.rhtml where line #10 raised: > > undefined method `some_names'' for #<Array:0xb757f654> > > > > Extracted source (around line #10): > > > > 7: <div style="border:3px solid #999"> > > 8: <% form_for :categories, :url => {:action => "show_tasks"} do | > > form| %> > > 9: Select Category: > > 10: <%= form.select "some_names", %w{Chris, Andy, Wally} %> > > 11: <%= submit_tag "View" %> > > 12: <% end %> > > 13: </div> > > > > > > > > > > > > On Apr 8, 6:18 pm, "chris" <olsen.ch...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Since I am just playing around with things I am constantly re- > > > formatting how things are arranged on the screen. How this is > > > supposed to work, is that at the top of the screen there is a select > > > list containing the categories, that combined within the button beside > > > it, allows the user to easily view the todo''s for each of the > > > categories. > > > > > > So the select control that I am having problems with isn''t yet, at the > > > time of the problem, related to the tasks just yet. I want to fill > > > the select control with all the categories that exist in the database. > > > > > > Thanks for the help, I really appreciate it. > > > > > > On Apr 8, 5:23 pm, "Conrad Taylor" <conra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > Hi Chris, you should be able to do the following: > > > > > > > <%= form.collection_select ''task'', ''category_id'', @categories, ''id'', > > > > ''<some_category_attribute>'' %> > > > > > > > This invocation will generate a select tag name="task[category_id]" with > > > > options of form <option > > > > value="category.id">category.<some_category_attribute></option>. The > > > > option with category.id == user.category_id will be selected. > > > > > > > Now, I''m guessing the following from you previous e-mail: > > > > > > > task belongs_to category > > > > category has_many tasks > > > > > > > Thus, I''m seeing the following relationship: > > > > > > > class Task < ActiveRecord::Base > > > > belongs_to :category > > > > end > > > > > > > class Category < ActiveRecord::Base > > > > has_many :tasks > > > > end > > > > > > > Please note that Task model contains the foreign key, ''category_id'', > > > > because it has the belongs_to declaration. > > > > > > > Good luck, > > > > > > > -Conrad > > > > > > > On 4/8/07, chris <olsen.ch...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > Sorry, I should''ve mentioned that there has been no changes to the > > > > > controller since I had it working. > > > > > Here is the index method from the controller > > > > > > > > def index > > > > > @categories = Category.find(:all) > > > > > @tasks = [] > > > > > end > > > > > > > > But the error is in regards to to the *select control. If I remove > > > > > line 10 from the index.rhtml file it renders to the browser without > > > > > any errors. > > > > > > > > On Apr 8, 3:11 pm, Jodi Showers <j...-BOB1p6JRLoAV+D8aMU/kSg@public.gmane.org> wrote: > > > > > > On 8-Apr-07, at 4:58 PM, chris wrote: > > > > > > > > > > I think I am going blind, because I cannot find what is wrong with the > > > > > > > following. The bad thing is that I had it working, made couple of > > > > > > > changes, reverted back to the original, now it doesn''t work. > > > > > > > > > > I have been trying to figure out why this isn''t working way too long, > > > > > > > to the point my vision is blurring. > > > > > > > > > > <div style="border:3px solid #999"> > > > > > > > <% form_for :categories, :url => {:action => "show_tasks"} do |form| > > > > > > > %> > > > > > > > Select Category: > > > > > > > <%= form.collection_select :name, @categories, :id, :name %> > > > > > > > <%= submit_tag "View" %> > > > > > > > <% end %> > > > > > > > </div> > > > > > > > > > > here is the error message > > > > > > > > > > NoMethodError in Mytasks#index > > > > > > > Showing app/views/mytasks/index.rhtml where line #10 raised: > > > > > > > undefined method `name'' for #<Array:0xb7611edc> > > > > > > > > > > Extracted source (around line #10): > > > > > > > > > > 7: <div style="border:3px solid #999"> > > > > > > > 8: <% form_for :categories, :url => {:action => "show_tasks"} do | > > > > > > > form| %> > > > > > > > 9: Select Category: > > > > > > > 10: <%= form.collection_select :name, @categories, :id, :name %> > > > > > > > 11: <%= submit_tag "View" %> > > > > > > > 12: <% end %> > > > > > > > 13: </div> > > > > > > > > > Chris, @categories is your problem. > > > > > > > > > collection_select is iterating through @categories looking for > > > > > > category.name. > > > > > > > > > Take a look at your controller where you''re populating @categories. > > > > > > > > > Cheers, > > > > > > Jodi > > > > > > General Partner > > > > > > The nNovation Group inc.www.nnovation.ca/blog > > > > > > > > > on-innovation.gif > > > > > > 11KViewDownload > > > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
Here is the updated snippet from the rhtml file ++++++++++++++++++ <div style="border:3px solid #999"> <% form_for :categories, :url => {:action => "show_tasks"} do |form| %> Select Category: <%= form.select :brothers, Category::BROTHERS %> <%= submit_tag "View" %> <% end %> </div> Here is the addition of the BROTHERS array in the category model ++++++++++++++++++ class Category < ActiveRecord::Base has_many :tasks BROTHERS = [ ["1", "Chris"], ["2", "Tim"], ["3", "Tom"] ] end And here is the error :( ++++++++++++++++++++ NoMethodError in Mytasks#index Showing app/views/mytasks/index.rhtml where line #10 raised: undefined method `brothers'' for #<Array:0xb7739c4c> Extracted source (around line #10): 7: <div style="border:3px solid #999"> 8: <% form_for :categories, :url => {:action => "show_tasks"} do | form| %> 9: Select Category: 10: <%= form.select :brothers, Category::BROTHERS %> 11: <%= submit_tag "View" %> 12: <% end %> 13: </div> On Apr 8, 8:12 pm, "Conrad Taylor" <conra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, here''s the corrected version: > > category_type = [ > [ "Chris", "1" ], > [ "Andy", "2" ], > [ "Wally", "3" ] > ] > > On 4/8/07, Conrad Taylor <conra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi, you should be able to do the following: > > > 1) Define this in the relevant model. > > > category_type = [ > > [ "Chris", "1" ] > > [ "Andy", "2" ] > > [ "Wally", "3" ] > > ] > > > 2) Add this code to the relevant view. > > > <%= form.select :some_names, <class_name>::category_type %> > > > Note: <class_name> := The name of your model class. For example, > > > Category > > > Good luck, > > > -Conrad > > > On 4/8/07, chris <olsen.ch...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > maybe this will help. I totally removed the linkage to the categories > > > and tried to hard code some values, with some random names > > > > <div style="border:3px solid #999"> > > > <% form_for :categories, :url => {:action => "show_tasks"} do |form| > > > %> > > > Select Category: > > > <%= form.select "some_names", %w{Chris, Andy, Wally} %> > > > <%= submit_tag "View" %> > > > <% end %> > > > </div> > > > > Here is the error message > > > ==================> > > NoMethodError in Mytasks#index > > > Showing app/views/mytasks/index.rhtml where line #10 raised: > > > undefined method `some_names'' for #<Array:0xb757f654> > > > > Extracted source (around line #10): > > > > 7: <div style="border:3px solid #999"> > > > 8: <% form_for :categories, :url => {:action => "show_tasks"} do | > > > form| %> > > > 9: Select Category: > > > 10: <%= form.select "some_names", %w{Chris, Andy, Wally} %> > > > 11: <%= submit_tag "View" %> > > > 12: <% end %> > > > 13: </div> > > > > On Apr 8, 6:18 pm, "chris" <olsen.ch...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Since I am just playing around with things I am constantly re- > > > > formatting how things are arranged on the screen. How this is > > > > supposed to work, is that at the top of the screen there is a select > > > > list containing the categories, that combined within the button beside > > > > it, allows the user to easily view the todo''s for each of the > > > > categories. > > > > > So the select control that I am having problems with isn''t yet, at the > > > > time of the problem, related to the tasks just yet. I want to fill > > > > the select control with all the categories that exist in the database. > > > > > Thanks for the help, I really appreciate it. > > > > > On Apr 8, 5:23 pm, "Conrad Taylor" <conra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > Hi Chris, you should be able to do the following: > > > > > > <%= form.collection_select ''task'', ''category_id'', @categories, ''id'', > > > > > ''<some_category_attribute>'' %> > > > > > > This invocation will generate a select tag name="task[category_id]" with > > > > > options of form <option > > > > > value="category.id">category.<some_category_attribute></option>. The > > > > > option with category.id == user.category_id will be selected. > > > > > > Now, I''m guessing the following from you previous e-mail: > > > > > > task belongs_to category > > > > > category has_many tasks > > > > > > Thus, I''m seeing the following relationship: > > > > > > class Task < ActiveRecord::Base > > > > > belongs_to :category > > > > > end > > > > > > class Category < ActiveRecord::Base > > > > > has_many :tasks > > > > > end > > > > > > Please note that Task model contains the foreign key, ''category_id'', > > > > > because it has the belongs_to declaration. > > > > > > Good luck, > > > > > > -Conrad > > > > > > On 4/8/07, chris <olsen.ch...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > Sorry, I should''ve mentioned that there has been no changes to the > > > > > > controller since I had it working. > > > > > > Here is the index method from the controller > > > > > > > def index > > > > > > @categories = Category.find(:all) > > > > > > @tasks = [] > > > > > > end > > > > > > > But the error is in regards to to the *select control. If I remove > > > > > > line 10 from the index.rhtml file it renders to the browser without > > > > > > any errors. > > > > > > > On Apr 8, 3:11 pm, Jodi Showers <j...-BOB1p6JRLoAV+D8aMU/kSg@public.gmane.org> wrote: > > > > > > > On 8-Apr-07, at 4:58 PM, chris wrote: > > > > > > > > > I think I am going blind, because I cannot find what is wrong with the > > > > > > > > following. The bad thing is that I had it working, made couple of > > > > > > > > changes, reverted back to the original, now it doesn''t work. > > > > > > > > > I have been trying to figure out why this isn''t working way too long, > > > > > > > > to the point my vision is blurring. > > > > > > > > > <div style="border:3px solid #999"> > > > > > > > > <% form_for :categories, :url => {:action => "show_tasks"} do |form| > > > > > > > > %> > > > > > > > > Select Category: > > > > > > > > <%= form.collection_select :name, @categories, :id, :name %> > > > > > > > > <%= submit_tag "View" %> > > > > > > > > <% end %> > > > > > > > > </div> > > > > > > > > > here is the error message > > > > > > > > > NoMethodError in Mytasks#index > > > > > > > > Showing app/views/mytasks/index.rhtml where line #10 raised: > > > > > > > > undefined method `name'' for #<Array:0xb7611edc> > > > > > > > > > Extracted source (around line #10): > > > > > > > > > 7: <div style="border:3px solid #999"> > > > > > > > > 8: <% form_for :categories, :url => {:action => "show_tasks"} do | > > > > > > > > form| %> > > > > > > > > 9: Select Category: > > > > > > > > 10: <%= form.collection_select :name, @categories, :id, :name %> > > > > > > > > 11: <%= submit_tag "View" %> > > > > > > > > 12: <% end %> > > > > > > > > 13: </div> > > > > > > > > Chris, @categories is your problem. > > > > > > > > collection_select is iterating through @categories looking for > > > > > > > category.name. > > > > > > > > Take a look at your controller where you''re populating @categories. > > > > > > > > Cheers, > > > > > > > Jodi > > > > > > > General Partner > > > > > > > The nNovation Group inc.www.nnovation.ca/blog > > > > > > > > on-innovation.gif > > > > > > > 11KViewDownload--~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---