Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7755121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:29:20+00:00 2026-06-01T12:29:20+00:00

I am learning Ruby on Rails and i did this scaffolding command: rails g

  • 0

I am learning Ruby on Rails and i did this scaffolding command:

rails g scaffold Alex

and it ran and created all the resources for me. So I tried to make a link from my index page to the alex page like this:

<%= link_to "Alex Link", alex_path(@alex) %>

(I am still not sure what that @alex part is, but it was in the other examples so I tried to have that there)

and in my routes.rb this code was created:

  resources :alexes

  get "home/index"

and when I tried to load the link, it gave me this error:

No route matches {:action=>"show", :controller=>"alexes"}

Just in case, here is the output from rake routes:

    alexes GET    /alexes(.:format)          alexes#index
           POST   /alexes(.:format)          alexes#create
  new_alex GET    /alexes/new(.:format)      alexes#new
 edit_alex GET    /alexes/:id/edit(.:format) alexes#edit
      alex GET    /alexes/:id(.:format)      alexes#show
           PUT    /alexes/:id(.:format)      alexes#update
           DELETE /alexes/:id(.:format)      alexes#destroy
home_index GET    /home/index(.:format)      home#index
      root        /                          home#index
      test POST   /test(.:format)            tests#create
  new_test GET    /test/new(.:format)        tests#new
 edit_test GET    /test/edit(.:format)       tests#edit
           GET    /test(.:format)            tests#show
           PUT    /test(.:format)            tests#update
           DELETE /test(.:format)            tests#destroy

What is wrong with the way that I made the link and how can I make it hit the controller before it goes to the view?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T12:29:21+00:00Added an answer on June 1, 2026 at 12:29 pm

    alex_path is for showing a specific Alex object. To use it, @alex needs to be an instance of an Alex object loaded by your controller.

    You say you want to link to the “Alex page”, which makes me think you want the listing of all Alex objects, or the index action of your AlexController. If this is the case, you should use alexes_path instead of alex_path(@alex).

    If you actually do want to link to a single specific Alex, you’ll need to load an instance from the database:

    def my_action
      # make a specific Alex object available to the view
      @alex = Alex.find(...)
    end
    

    As an aside, you also ask:

    how can I make it hit the controller before it goes to the view?

    Your controller will always be hit before the views are rendered. It is impossible for a view to be rendered without an action being invoked.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently learning Ruby on Rails. I currently do all my development on
Hey, I'm just learning ruby on rails and I've been stumped on this for
I've just started learning Ruby on Rails and it's a newbie question. I did
I am learning Ruby on Rails so I'm sure I'll find this out sooner
I am learning ruby on rails using aptana studio 3. I created a view
I am learning ruby on rails. So, I created a sample application in which
I am learning ruby from this guide http://ruby.railstutorial.org/ruby-on-rails-tutorial-book#sec:deploying , and I am trying to
I'm just learning ruby on rails and I have a table of user roles
I'm learning Ruby on Rails and doing the contactlist thing, 20 minute blog and
I'm learning Ruby on Rails. I'm using some associations (has_many :through, ...) But i'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.