user1779563
user1779563

Reputation: 810

Rails route not working

I created a new route and a corresponding method in a controller and view:

routes.rb:

get "pictures/user/:username" => 'Pictures#user'

pictures_controller.rb:

def user
  @pictures_user = User.where(username: params[:username]).first
  render 'user.html.erb'
end

user.html.erb:

Just some simple html/erb

I get this following error. I know the user method is being entered, seems to be a problem rendering the view?

Routing Error

No route matches {:controller=>"pictures", :action=>"user", :username=>"my_username", :page=>nil}

What am I missing?

Upvotes: 0

Views: 2129

Answers (1)

Nich
Nich

Reputation: 1102

user.html.erb is inside the same directory of views/pictures? just do

render 'user'

should be fine i think

and I guess your Pictures downcase will be better @@

get "pictures/user/:username" => 'pictures#user'

Upvotes: 2

Related Questions