Two buttons respond to same action

Hey
I am using rails 3.0.7.I created two buttons simply as:
<%= button_to “Great”, :action => “click”%>
<%= button_to “click me”, :action => “work”%>

Router.rb file looks like:

Check::Application.routes.draw do

get “gne/clg”

get “posts/index”
resources :posts do
end
#get ‘posts/click’

ActionController::Routing::Routes.draw do |map|
map.root :controller => “posts”, :action => “click”
end

ActionController::Routing::Routes.draw do |map|
map.root :controller => “posts”, :action => “work”
end
end

        When i click any button both respond to

/app/view/posts/click.html.erb while i have another file work.html.erb
in
same directory for other button .Whats problem may be?

Amrit

On May 28, 3:06pm, amritpal pathak [email protected] wrote:

get “posts/index”
end
end

First off you don’t need that ActionController::Routing::Routes.draw
stuff if you use the rails 3 syntax.
root :to => “posts#click”

Secondly you’re mapping both your actions to the same path - you need
to map them to different paths if you want rails to know which action
to route to when the request arrives.

Fred

Fred

On Sat, May 28, 2011 at 11:30 AM, Frederick C. <
[email protected]> wrote:

Check::Application.routes.draw do

to map them to different paths if you want rails to know which action
to route to when the request arrives.

Third please stop posting the same question as two different people
(John S
Shelfer and Amritpal Pathak). Use one email address and one identity
then
wait for someone to respond.

B.

On 28 May 2011 19:24, Bryan C. [email protected] wrote:

Router.rb file looks like:
map.root :controller => “posts”, :action => “click”

Secondly you’re mapping both your actions to the same path - you need
to map them to different paths if you want rails to know which action
to route to when the request arrives.

Third please stop posting the same question as two different people (John S
Shelfer and Amritpal Pathak). Use one email address and one identity then
wait for someone to respond.

I had not realised till just now that John Shelfer is also Amritpal
Pathak that has caused so much strain on our patience in the past. I
think he/she is a wind up merchant just getting us all to waste our
time.

Colin

On 28 May 2011 20:45, Colin L. [email protected] wrote:

I had not realised till just now that John Shelfer is also Amritpal
Pathak

oops! I thought you were just being really patient…

I think he/she is a wind up merchant just getting us all to waste
our time.

+1

On Sat, May 28, 2011 at 2:24 PM, Bryan C.
[email protected]wrote:

ActionController::Routing::Routes.draw do |map|
root :to => “posts#click”

Secondly you’re mapping both your actions to the same path - you need
to map them to different paths if you want rails to know which action
to route to when the request arrives.

Third please stop posting the same question as two different people (John S
Shelfer and Amritpal Pathak). Use one email address and one identity then
wait for someone to respond.

  Ok

I think I can speak for most people (yeah notice the most, didnt want
to speak for everybody) here in saying, no we cant.

On Sat, May 28, 2011 at 12:30 PM, Frederick C. <
[email protected]> wrote:

Check::Application.routes.draw do

ActionController::Routing::Routes.draw do |map|
map.root :controller => “posts”, :action => “work”
end
end

First off you don’t need that ActionController::Routing::Routes.draw
stuff if you use the rails 3 syntax.
root :to => “posts#click”

 Thanks for help.It worked.

Secondly you’re mapping both your actions to the same path - you need
to map them to different paths if you want rails to know which action
to route to when the request arrives.

 Can you tell please how to map both actions to different paths.I
 am new to rails so dont know OR any good tutorial that can help.

On Sun, May 29, 2011 at 4:12 AM, Chris K. [email protected]
wrote:

This should be everyone’s starting point when first learning about Rails
routing: Rails Routing from the Outside In — Ruby on Rails Guides

Read it a couple of times at least. If you’re still unsure, at least
you’ll
have enough context to come back and ask specific questions about the
parts
you don’t understand.

On Sun, May 29, 2011 at 7:16 AM, amritpal pathak
[email protected]wrote:

I followed Section 2.9.1 for adding a route to single action of
controller as:

     resources :posts do
    member do
    get 'click'
    end
    end
                                 But it still gave routing error
       No route matches {:controller=>"posts", :action=>"click"}

Thank you

On 29 May 2011 13:17, amritpal pathak [email protected] wrote:

routing:Rails Routing from the Outside In — Ruby on Rails Guides
end
end
But it still gave routing error
No route matches {:controller=>“posts”, :action=>“click”}
Thank you

It seems clear from posts recently that Amritpal Pathak and John
Shelfer are one and the same. He has been posting the same questions
under both names. Readers may find it interesting to read
http://www.ruby-forum.com/topic/1610794
where he posts under both aliases, thanking himself for support. It
is clear that the guy is not genuine.

I think you will have to get yourself a new name John/Amritpal

Colin

On Sun, May 29, 2011 at 8:29 AM, Colin L. [email protected]
wrote:

On 29 May 2011 13:29, Colin L. [email protected] wrote:

Readers may find it interesting to read
"uninitialized constant PostsController::Post" - Rails - Ruby-Forum
where he posts under both aliases, thanking himself for support.

Good effort. I’d forgotten about that thread (there were so many…)

It is clear that the guy is not genuine.

I don’t think he’s necessarily taking the p***, but he’s certainly not
putting in the effort (or is not able to?) to work towards solving his
own problems. How many times have you and others said “rake routes”?
Remembering previous advice is essential to building skills, and
learning where to find stuff out for oneself (again… I’ve never seen
so many URLs pointing to the routing guides as have been in
Amritpal/John threads) means you don’t have to keep wasting peoples’
time with the same questions.

On 29 May 2011 13:33, amritpal pathak [email protected] wrote:

about the
No route matches {:controller=>“posts”, :action=>“click”}
posted it from amrit aliase due to any network problem or something else ,it
didn’t show at mailing list.So i was worried and posted it from other aliase
too.

Can you explain then why in "uninitialized constant PostsController::Post" - Rails - Ruby-Forum
when I said “Am I the only one thinking this poster is winding us up?”
referring to yourself as Amrit that yourself as John replied " Not at
all.He is new to Rails So I think we should help him to resolve the
issue." and you as Amrit then replied again “Thank you for your
support sir”.

Colin

Sent from my iPhone

On May 29, 2011, at 8:47 AM, amritpal pathak [email protected]
wrote:

routing: Rails Routing from the Outside In — Ruby on Rails Guides
get ‘click’
where he posts under both aliases, thanking himself for support. It
all.He is new to Rails So I think we should help him to resolve the
issue." and you as Amrit then replied again “Thank you for your
support sir”.
Yes .You are right colin.I did this mistake .I replied from both aliases here
because i hadn’t want to create an issue(Guilt was mine ).So to terminate the
thread i did it.NOw i ensure you ,it will not happen again.
I request to all of you please give me a chance to prove myself.

Thank you.

Use the troubleshooting skills that everyone has been teaching you.
They’ve given you advice on how to check for why you can’t see that
route and learn more about it. Demonstrate that you are learning from
that advice. That is how you earn that chance.

B.

On Sun, May 29, 2011 at 8:44 AM, Colin L. [email protected]
wrote:

On Sun, May 29, 2011 at 7:16 AM, amritpal pathak

routing: Rails Routing from the Outside In — Ruby on Rails Guides
member do
"uninitialized constant PostsController::Post" - Rails - Ruby-Forum

Can you explain then why in "uninitialized constant PostsController::Post" - Rails - Ruby-Forum
when I said “Am I the only one thinking this poster is winding us up?”
referring to yourself as Amrit that yourself as John replied " Not at
all.He is new to Rails So I think we should help him to resolve the
issue." and you as Amrit then replied again “Thank you for your
support sir”.
Yes .You are right colin.I did this mistake .I replied from both aliases
here because i hadn’t want to create an issue(Guilt was mine ).So to
terminate the thread i did it.NOw i ensure you ,it will not happen again.

I request to all of you please give me a chance to prove myself.

Thank you.