I generated a simple controller using "script/generate controller form myfun".Then edited a /app/view/form/myfun.html.erb simply as <h1>Hello</h1> <%=link_to ''Submit''%> I created a another controller using "script/generate controller click fun".Edited the app/ view/click/fun.html.erb to hold a welcome message as <h1>Welcome</h1> I want click on submit should show this message,but dont know how to connect these two controllers.using rails .I am using rails 3.0.7. Please somebody guide me Thanks -- 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.
On 23 April 2011 13:18, amrit pal pathak <amritpalpathak1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I generated a simple controller using "script/generate controller form > myfun".Then edited a /app/view/form/myfun.html.erb simply as > <h1>Hello</h1> > <%=link_to ''Submit''%> > > I created a another > controller using "script/generate controller click fun".Edited the app/ > view/click/fun.html.erb to hold a welcome message as > > <h1>Welcome</h1> > I want click on > submit should show this message,but dont know how to connect these two > controllers.using rails .I am using rails 3.0.7.It is important to distinguish between the three components Model View Controller of MVC design. If you are not clear on these then some googling and reading might be worthwhile. I presume that what you actually want to do is link to a controller action from the _view_ of another controller. To do that simply put use link_to to link to the the controller/action that you want. I think I suggested in a reply to one of your earlier questions (if it was you, apologies if not) that you worked right through some tutorials, the free to use online one at railstutorial.org is very good. Once you have done that then these very basic questions that you are asking will not need to be asked. Colin -- 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.
On Apr 23, 8:26 am, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 23 April 2011 13:18, amrit pal pathak <amritpalpath...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > I generated a simple controller using "script/generate controller form > > myfun".Then edited a /app/view/form/myfun.html.erb simply as > > <h1>Hello</h1> > > <%=link_to ''Submit''%> > > > I created a another > > controller using "script/generate controller click fun".Edited the app/ > > view/click/fun.html.erb to hold a welcome message as > > > <h1>Welcome</h1> > > I want click on > > submit should show this message,but dont know how to connect these two > > controllers.using rails .I am using rails 3.0.7. > > It is important to distinguish between the three components Model View > Controller of MVC design. If you are not clear on these then some > googling and reading might be worthwhile. I presume that what you > actually want to do is link to a controller action from the _view_ of > another controller. To do that simply put use link_to to link to the > the controller/action that you want.I add the link to click controller(it has a fun action) as ,but i gave error(may be a syntax error in specifying a controller path). <h1>Hello</h1> <%=link_to ''Submit'',click_path%> Help.> I think I suggested in a reply to one of your earlier questions (if it > was you, apologies if not) that you worked right through some > tutorialsYes it was me.i read the tutorils and tried to understand.i am not a hard core programmer.i am a student sir,thats why asking these basic questions. Thanks -- 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.
On 23 April 2011 13:40, amrit pal pathak <amritpalpathak1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On Apr 23, 8:26 am, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: >> On 23 April 2011 13:18, amrit pal pathak <amritpalpath...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> >> >> > I generated a simple controller using "script/generate controller form >> > myfun".Then edited a /app/view/form/myfun.html.erb simply as >> > <h1>Hello</h1> >> > <%=link_to ''Submit''%> >> >> > I created a another >> > controller using "script/generate controller click fun".Edited the app/ >> > view/click/fun.html.erb to hold a welcome message as >> >> > <h1>Welcome</h1> >> > I want click on >> > submit should show this message,but dont know how to connect these two >> > controllers.using rails .I am using rails 3.0.7. >> >> It is important to distinguish between the three components Model View >> Controller of MVC design. If you are not clear on these then some >> googling and reading might be worthwhile. I presume that what you >> actually want to do is link to a controller action from the _view_ of >> another controller. To do that simply put use link_to to link to the >> the controller/action that you want. > I add the link to click controller(it has a fun action)You are confusing controller and view again, you cannot add a link to a controller, only to a view.> as ,but i gave error(may be a syntax error in specifying a controller > path). > <h1>Hello</h1> > <%=link_to ''Submit'',click_path%>That should probably be clicks_path (plural). If you run rake routes it will show you the routes you have defined, one of which will be something like clicks GET /clicks(.:format) {:controller=>"clicks", :action=>"index"} which will tell you that clicks_path is a valid route. Colin -- 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.
On Apr 23, 10:11 am, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 23 April 2011 13:40, amrit pal pathak <amritpalpath...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > > > > > On Apr 23, 8:26 am, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > >> On 23 April 2011 13:18, amrit pal pathak <amritpalpath...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > >> > I generated a simple controller using "script/generate controller form > >> > myfun".Then edited a /app/view/form/myfun.html.erb simply as > >> > <h1>Hello</h1> > >> > <%=link_to ''Submit''%> > > >> > I created a another > >> > controller using "script/generate controller click fun".Edited the app/ > >> > view/click/fun.html.erb to hold a welcome message as > > >> > <h1>Welcome</h1> > >> > I want click on > >> > submit should show this message,but dont know how to connect these two > >> > controllers.using rails .I am using rails 3.0.7. > > >> It is important to distinguish between the three components Model View > >> Controller of MVC design. If you are not clear on these then some > >> googling and reading might be worthwhile. I presume that what you > >> actually want to do is link to a controller action from the _view_ of > >> another controller. To do that simply put use link_to to link to the > >> the controller/action that you want. > > I add the link to click controller(it has a fun action) > > You are confusing controller and view again, you cannot add a link to > a controller, only to a view. > > > as ,but i gave error(may be a syntax error in specifying a controller > > path). > > <h1>Hello</h1> > > <%=link_to ''Submit'',click_path%> > > That should probably be clicks_path (plural).Now i gave plural ,again error <h1>Hello</h1> <%=link_to ''Submit'',clicks_path %> Error is undefined local variable or method `clicks_path'' for #<#<Class: 0xb66b347c>:0xb66b1fa0> Thanks -- 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.
On 23 April 2011 16:48, amrit pal pathak <amritpalpathak1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> ... > Now i gave plural ,again error > <h1>Hello</h1> > <%=link_to ''Submit'',clicks_path %> > > Error is > undefined local variable or method `clicks_path'' for #<#<Class: > 0xb66b347c>:0xb66b1fa0>And the result from rake routes? You did try that didn''t you? Colin -- 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.
On Apr 23, 11:58 am, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 23 April 2011 16:48, amrit pal pathak <amritpalpath...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > ... > > Now i gave plural ,again error > > <h1>Hello</h1> > > <%=link_to ''Submit'',clicks_path %> > > > Error is > > undefined local variable or method `clicks_path'' for #<#<Class: > > 0xb66b347c>:0xb66b1fa0> > > And the result from rake routes? You did try that didn''t you?i did it gives click_fun GET /click/fun(.:format) {:action=>"fun", :controller=>"click"} home_index GET /home/index(.:format) {:action=>"index", :controller=>"home"} root /(.:format) {:action=>"index", :controller=>"home"} Thanks -- 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.
On 23 April 2011 17:04, amrit pal pathak <amritpalpathak1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On Apr 23, 11:58 am, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: >> On 23 April 2011 16:48, amrit pal pathak <amritpalpath...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> > ... >> > Now i gave plural ,again error >> > <h1>Hello</h1> >> > <%=link_to ''Submit'',clicks_path %> >> >> > Error is >> > undefined local variable or method `clicks_path'' for #<#<Class: >> > 0xb66b347c>:0xb66b1fa0> >> >> And the result from rake routes? You did try that didn''t you? > i did it gives > > click_fun GET /click/fun(.:format) > {:action=>"fun", :controller=>"click"} > home_index GET /home/index(.:format) > {:action=>"index", :controller=>"home"} > root /(.:format) > {:action=>"index", :controller=>"home"}So why did you not say last time that the clicks routes are not there? If you have not got the routes setup then the _path variables will not be defined. I suggest you read the Rails Guide on Routing. Colin -- 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.
On Apr 23, 5:04 pm, amrit pal pathak <amritpalpath...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Apr 23, 11:58 am, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 23 April 2011 16:48, amrit pal pathak <amritpalpath...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > And the result from rake routes? You did try that didn''t you? > > i did it gives > > click_fun GET /click/fun(.:format) > {:action=>"fun", :controller=>"click"} > home_index GET /home/index(.:format) > {:action=>"index", :controller=>"home"} > root /(.:format) > {:action=>"index", :controller=>"home"} >This means that the URL helpers that exist are click_fun_path, home_index_path and root_path. You can use clicks_path because it doesn''t exist. Fred> Thanks-- 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.
On Apr 23, 12:11 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Apr 23, 5:04 pm, amrit pal pathak <amritpalpath...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote:> On Apr 23, 11:58 am, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 23 April 2011 16:48, amrit pal pathak <amritpalpath...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > And the result from rake routes? You did try that didn''t you? > > > i did it gives > > > click_fun GET /click/fun(.:format) > > {:action=>"fun", :controller=>"click"} > > home_index GET /home/index(.:format) > > {:action=>"index", :controller=>"home"} > > root /(.:format) > > {:action=>"index", :controller=>"home"} > > This means that the URL helpers that exist are click_fun_path, > home_index_path and root_path. > You can use clicks_path because it doesn''t exist.It was path syntax error.Now i used "<%=link_to ''Submit'',click_fun_path %>" and it worked. please tell me one thing ,click_fun_path is path to click controller or click view?? Thanks to colin and Frederick Cheung. -- 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.
On 24 April 2011 06:45, amrit pal pathak <amritpalpathak1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On Apr 23, 12:11 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: >> On Apr 23, 5:04 pm, amrit pal pathak <amritpalpath...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >> wrote:> On Apr 23, 11:58 am, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 23 April 2011 16:48, amrit pal pathak <amritpalpath...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> > > And the result from rake routes? You did try that didn''t you? >> >> > i did it gives >> >> > click_fun GET /click/fun(.:format) >> > {:action=>"fun", :controller=>"click"} >> > home_index GET /home/index(.:format) >> > {:action=>"index", :controller=>"home"} >> > root /(.:format) >> > {:action=>"index", :controller=>"home"} >> >> This means that the URL helpers that exist are click_fun_path, >> home_index_path and root_path. >> You can use clicks_path because it doesn''t exist. > > It was path syntax error.Now i used > "<%=link_to ''Submit'',click_fun_path %>" and it worked. > please tell me one thing ,click_fun_path is path to click > controller or click view??As I suggested previously it would be worth your while reading up on MVC architecture, as it is fundamental to Rails apps. There is no such thing as a link to a view, links are always to controller actions. Also as pointed out previously you can see that from the output of rake routes that you posted: click_fun GET /click/fun(.:format) {:action=>"fun", :controller=>"click"} That says that click_fun_path is a route with url click/fun (with optional format) which will run controller click, action fun. Colin -- 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.
On Apr 24, 2:52 am, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 24 April 2011 06:45, amrit pal pathak <amritpalpath...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > > > > > On Apr 23, 12:11 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > wrote: > >> On Apr 23, 5:04 pm, amrit pal pathak <amritpalpath...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > >> wrote:> On Apr 23, 11:58 am, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 23 April 2011 16:48, amrit pal pathak <amritpalpath...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > >> > > And the result from rake routes? You did try that didn''t you? > > >> > i did it gives > > >> > click_fun GET /click/fun(.:format) > >> > {:action=>"fun", :controller=>"click"} > >> > home_index GET /home/index(.:format) > >> > {:action=>"index", :controller=>"home"} > >> > root /(.:format) > >> > {:action=>"index", :controller=>"home"} > > >> This means that the URL helpers that exist are click_fun_path, > >> home_index_path and root_path. > >> You can use clicks_path because it doesn''t exist. > > > It was path syntax error.Now i used > > "<%=link_to ''Submit'',click_fun_path %>" and it worked. > > please tell me one thing ,click_fun_path is path to click > > controller or click view?? > > As I suggested previously it would be worth your while reading up on > MVC architecture, as it is fundamental to Rails apps. There is no > such thing as a link to a view, links are always to controllerOK Thank you colin :P -- 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.