slindsey3000
2010-Apr-13 23:44 UTC
params[hash] and link_to.... easy question... but I am stupid :)
routes.rb map.connect '':controller/:action/:id/:draw_id'', :controller => "admin", :action => "edit_position" In a view I have: <%= link_to "#{@draw.positions[0].team}", { :controller => :admin, :action => :edit_position, :id =>@draw.positions[0].id, :draw_id => @draw.id } %> In my controller I do not receive the param :draw_id in my params[] Any thoughts? How do I do a link_to and pass in these 2 parameters :id and :draw_id Thanks! Shawn -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Craig White
2010-Apr-13 23:54 UTC
Re: params[hash] and link_to.... easy question... but I am stupid :)
On Tue, 2010-04-13 at 16:44 -0700, slindsey3000 wrote:> routes.rb > > map.connect '':controller/:action/:id/:draw_id'', :controller => > "admin", :action => "edit_position" > > > In a view I have: > > <%= link_to "#{@draw.positions[0].team}", { :controller > => :admin, :action => :edit_position, > :id > =>@draw.positions[0].id, :draw_id => @draw.id } %> > > In my controller I do not receive the param :draw_id in my params[] > > > > Any thoughts? How do I do a link_to and pass in these 2 > parameters :id and :draw_id---- the param :draw_id would be sent as a parameter... http://www.example.com/controller/action/id?draw_id=1 thus, there really is no need to represent it in routes.rb Craig -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
slindsey3000
2010-Apr-14 00:00 UTC
Re: params[hash] and link_to.... easy question... but I am stupid :)
It is not in my params hash though.... I initially did nothing with my routes.rb... then seeing that the only param I got was :id, I started playing around. can anyone give me an example of a link_to that sends 2 parameters to a controller. This seems so silly, but I am stuck. Thanks so much... On Apr 13, 4:54 pm, Craig White <craigwh...-BQ75lA0ptkhBDgjK7y7TUQ@public.gmane.org> wrote:> On Tue, 2010-04-13 at 16:44 -0700, slindsey3000 wrote: > > routes.rb > > > map.connect '':controller/:action/:id/:draw_id'', :controller => > > "admin", :action => "edit_position" > > > In a view I have: > > > <%= link_to "#...@draw.positions[0].team}", { :controller > > => :admin, :action => :edit_position, > > :id > > =>@draw.positions[0].id, :draw_id => @draw.id } %> > > > In my controller I do not receive the param :draw_id in my params[] > > > Any thoughts? How do I do a link_to and pass in these 2 > > parameters :id and :draw_id > > ---- > the param :draw_id would be sent as a parameter... > > http://www.example.com/controller/action/id?draw_id=1 > > thus, there really is no need to represent it in routes.rb > > Craig > > -- > This message has been scanned for viruses and > dangerous content by MailScanner, and is > believed to be clean.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Me
2010-Apr-14 00:52 UTC
Re: params[hash] and link_to.... easy question... but I am stupid :)
link_to "link", :controller => "articles", :id => id, :draw_id => @draw.id On Apr 13, 7:00 pm, slindsey3000 <slindsey3...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> It is not in my params hash though.... > > I initially did nothing with my routes.rb... then seeing that the only > param I got was :id, I started playing around. > > can anyone give me an example of a link_to that sends 2 parameters to > a controller. > > This seems so silly, but I am stuck. > > Thanks so much... > > On Apr 13, 4:54 pm, Craig White <craigwh...-BQ75lA0ptkhBDgjK7y7TUQ@public.gmane.org> wrote: > > > On Tue, 2010-04-13 at 16:44 -0700, slindsey3000 wrote: > > > routes.rb > > > > map.connect '':controller/:action/:id/:draw_id'', :controller => > > > "admin", :action => "edit_position" > > > > In a view I have: > > > > <%= link_to "#...@draw.positions[0].team}", { :controller > > > => :admin, :action => :edit_position, > > > :id > > > =>@draw.positions[0].id, :draw_id => @draw.id } %> > > > > In my controller I do not receive the param :draw_id in my params[] > > > > Any thoughts? How do I do a link_to and pass in these 2 > > > parameters :id and :draw_id > > > ---- > > the param :draw_id would be sent as a parameter... > > >http://www.example.com/controller/action/id?draw_id=1 > > > thus, there really is no need to represent it in routes.rb > > > Craig > > > -- > > This message has been scanned for viruses and > > dangerous content by MailScanner, and is > > believed to be clean.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
slindsey3000
2010-Apr-14 01:33 UTC
Re: params[hash] and link_to.... easy question... but I am stupid :)
Sure... but how would you access the :draw_id in your controller? It is not showing up in my params hash.... with what you wrote I only get :id in the hash as well as action and controller. On Apr 13, 5:52 pm, Me <chabg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> link_to "link", :controller => "articles", :id => id, :draw_id => > @draw.id > > On Apr 13, 7:00 pm, slindsey3000 <slindsey3...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > It is not in my params hash though.... > > > I initially did nothing with my routes.rb... then seeing that the only > > param I got was :id, I started playing around. > > > can anyone give me an example of a link_to that sends 2 parameters to > > a controller. > > > This seems so silly, but I am stuck. > > > Thanks so much... > > > On Apr 13, 4:54 pm, Craig White <craigwh...-BQ75lA0ptkhBDgjK7y7TUQ@public.gmane.org> wrote: > > > > On Tue, 2010-04-13 at 16:44 -0700, slindsey3000 wrote: > > > > routes.rb > > > > > map.connect '':controller/:action/:id/:draw_id'', :controller => > > > > "admin", :action => "edit_position" > > > > > In a view I have: > > > > > <%= link_to "#...@draw.positions[0].team}", { :controller > > > > => :admin, :action => :edit_position, > > > > :id > > > > =>@draw.positions[0].id, :draw_id => @draw.id } %> > > > > > In my controller I do not receive the param :draw_id in my params[] > > > > > Any thoughts? How do I do a link_to and pass in these 2 > > > > parameters :id and :draw_id > > > > ---- > > > the param :draw_id would be sent as a parameter... > > > >http://www.example.com/controller/action/id?draw_id=1 > > > > thus, there really is no need to represent it in routes.rb > > > > Craig > > > > -- > > > This message has been scanned for viruses and > > > dangerous content by MailScanner, and is > > > believed to be clean.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Colin Law
2010-Apr-14 08:26 UTC
Re: Re: params[hash] and link_to.... easy question... but I am stupid :)
On 14 April 2010 02:33, slindsey3000 <slindsey3000-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Sure... but how would you access the :draw_id in your controller? > > It is not showing up in my params hash.... with what you wrote I only > get :id in the hash as well as action and controller.Is draw_id showing in the log file (log/development.log). If not then @draw.id is probably nil. Have a look at the html of your page (View, Page source or similar in your browser) and see if it is there. Also you could try displaying @draw.id in the page to see what it is. By the way most think it better to insert your comments to previous emails inline rather than at the top. It makes it easier to follow the thread. Colin> > > > > On Apr 13, 5:52 pm, Me <chabg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> link_to "link", :controller => "articles", :id => id, :draw_id => >> @draw.id >> >> On Apr 13, 7:00 pm, slindsey3000 <slindsey3...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> > It is not in my params hash though.... >> >> > I initially did nothing with my routes.rb... then seeing that the only >> > param I got was :id, I started playing around. >> >> > can anyone give me an example of a link_to that sends 2 parameters to >> > a controller. >> >> > This seems so silly, but I am stuck. >> >> > Thanks so much... >> >> > On Apr 13, 4:54 pm, Craig White <craigwh...-BQ75lA0ptkhBDgjK7y7TUQ@public.gmane.org> wrote: >> >> > > On Tue, 2010-04-13 at 16:44 -0700, slindsey3000 wrote: >> > > > routes.rb >> >> > > > map.connect '':controller/:action/:id/:draw_id'', :controller => >> > > > "admin", :action => "edit_position" >> >> > > > In a view I have: >> >> > > > <%= link_to "#...@draw.positions[0].team}", { :controller >> > > > => :admin, :action => :edit_position, >> > > > :id >> > > > =>@draw.positions[0].id, :draw_id => @draw.id } %> >> >> > > > In my controller I do not receive the param :draw_id in my params[] >> >> > > > Any thoughts? How do I do a link_to and pass in these 2 >> > > > parameters :id and :draw_id >> >> > > ---- >> > > the param :draw_id would be sent as a parameter... >> >> > >http://www.example.com/controller/action/id?draw_id=1 >> >> > > thus, there really is no need to represent it in routes.rb >> >> > > Craig >> >> > > -- >> > > This message has been scanned for viruses and >> > > dangerous content by MailScanner, and is >> > > believed to be clean. > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.