Buttons's routing

Hey
My app has some buttons and i have route all to different
action
in router.rb file but click on each button results in same action. why?
Am i missing to specify anything…)

Rails:3.0.7

Thanks in advance.

Buttons are normally associated with forms, which post to the forms
action method - unless you have specified otherwise. A copy of your
view code would be really handy.

On 14 June 2011 07:19, amritpal pathak [email protected]
wrote:

Hey
My app has some buttons and i have route all to different action
in router.rb file but click on each button results in same action. why?
Am i missing to specify anything…)

Yes, obviously.
Show us the code for a couple of the buttons.
Have a look in the log to see what it says when you click the buttons.
Post the relevant sections here if you cannot see what is wrong.

Colin

On 14 June 2011 16:32, amritpal pathak [email protected]
wrote:

Routing.rb file has following stuff

Check::Application.routes.draw do
get “posts/index”
resources :posts do
end
root :to => “posts#click1”
root :to => “posts#click2”
end

I am sorry Amritpal (or John, if that is your name) I give up. You
still seem to have not idea how routing works. I have advised on
numerous occasions that you study the Rails Guide on routing and ask
here if there is something you do not understand. You have never (as
far as I recall) asked for clarification on any of the details in the
guide so presumably you understand it all, yet you obviously have no
idea.

Either you are winding us up or you need to seriously consider a
different hobby (or career, but hopefully it is just a hobby).

Sorry again

Colin

On Tue, Jun 14, 2011 at 3:46 AM, Colin L. [email protected]
wrote:

On 14 June 2011 07:19, amritpal pathak [email protected] wrote:

Hey
My app has some buttons and i have route all to different
action
in router.rb file but click on each button results in same action. why?
Am i missing to specify anything…)

Yes, obviously.
Show us the code for a couple of the buttons.

Buttons are generted using following code
  <%= button_to "Submit1", :action => "click1"%>
    <%= button_to "Submit2", :action => "click2"%>
                               Similarly other buttons have been
created.obviously there are files in view directory with
name click1,click2 and so on.

Routing.rb file has following stuff

Check::Application.routes.draw do
get “posts/index”
resources :posts do
end
root :to => “posts#click1”
root :to => “posts#click2”
end

Thank you

On Tue, Jun 14, 2011 at 12:09 PM, Colin L. [email protected]
wrote:

On Jun 14, 11:32am, amritpal pathak [email protected]
wrote:

Thank you
“root :to =>” is used to denote the HOME PAGE of your application.

Further, you’re going against Rails convention if you really have
actions like “click1” and “click2”.

Please read through and understood Rails Routing properly.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs