1. Provide the models required
2. Each article can be related to many articles (or none).Provide code
for making @article.related_articles work
3. Clean up the code according to rails conventions
class ArticleController < ApplicationController
def show
@article = Article.find(params[:id])
if current_user.roles.map {|r| r.to_s}.include?('admin')
@info = Info.find(:first, :conditions => "article_id =
#{@article.id}")
else
@info = nil
end
if params[:show_comments] && params[:show_comments] != ''
@comments = Comment.find(:first, :conditions => "article_id =
#{@article.id}")
end
if !(params[:hide_related] && params[:hide_related] != '')
@related_articles = @article.related_articles
end
end
end
What will be the solution for the above issue?
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
No comments:
Post a Comment