-1

I have a chat on action cable. I change my show action for this:

def show
  @rooms = Room.all
  render 'index'

  if @room = Room.find(params[:id])
  else
    render 'new'
  end
end

But i need to show to user a single room with another information. I create action:

def single_show
  @room = Room.find_by(params[:id])
end

It gives me only first room regardless from room which i choose. I understand it's from 'find_by', but i need to show every room which user choose. When i choose a room i get this route in browser:

http://localhost:3000/single_show.2

I think it's not right. My routes is:

resources :rooms
get 'single_show', to: 'rooms#single_show'

How I can show every room which user will chose?

Holger Just
  • 52,918
  • 14
  • 115
  • 123

1 Answers1

0

Please change routes get 'single_show', to: 'rooms#single_show' to get 'single_show/:id', to: 'rooms#single_show'

def single_show
  @room = Room.find_by(id: params[:id])
end```