I am writing a blog application in Rails where registered Users and allowed to create Article. These articles can be viewed by anyone (Without user account). The article/show.html.erb is fairly complex displaying additional information such as related articles etc... A simplified version of the code is below.
Models
class User < ActiveRecord::Base
has_many :articles
end
class Article < ActiveRecord::Base
belongs_to :user
end
Controller
class ArticlesController < ApplicationController
def show
@article = Articles.find(params[:id])
end
end
Once a user is signed in, the user should be able to view the articles similar to anyone without user account. So when signed in user clicks on an article article/show.html.erb is rendered. I want to provide a separate link for the signed in user to view his article in a separate view without the additional complex details mentioned previously.
How can I do this since controller action ArticleController#show is already mapped to article/show.html.erb.
It seems that this can be achieved by using an additional controller such as UserArticleController and userarticlecontroller/show.html.erb. But I wonder whether this may not be the Rails way of doing things and there may exist a better method for handling this kind of situations.