I am working on a new app in rails. I have already set up a user
model using Devise and a post
model and controller. What I want to be able to do is have a url like:
www.site.com/user/post
Which will show the post
layout for that specific user
. I am already using friendly_id
in order to use the title and username for the user and title id's.
Thanks.
答案 0 :(得分:0)
Try adding this to your routes.rb
file (after your devise_for
line):
devise_scope :user do
get "/user/post", to: "posts#show"
end
答案 1 :(得分:0)
If your models are like this:
class User < ActiveRecord::Base
has_many :post
end
class Post < ActiveRecord::Base
belongs_to :user
end
You can use something like this in your routes.rb:
resources :users do
resources :posts
end
This will give you possibility to have links like you want and you will be able to load which template you want.