Displaying 2 results from an estimated 2 matches for "newscategory".
Did you mean:
new_category
2006 Jul 03
0
Modelling Relationships as objects
DHH in Rails Confeerence pointed out that abstract relationships should be
converted into concrete objects, CRUDying up relationships.
An example would be
class User < ActiveRecord::Base
has_many :subscriptions
has_many :news_categories, :through => :subscriptions
end
class NewsCategory < ActiveRecord::Base
has_many :subscriptions
has_many :users, :through => :subscriptions
end
class Subscription < ActiveRecord::Base
belongs_to :user
belongs_to :news_category
end
User and NewsCategory(2 tables in database) have m:n relation and hence they
would require another...
2007 Jul 19
7
NoMethodError in partial driving me mad
...e "show_category" action is called, i get a NoMethodError while
displaying my news through the partial.
news_controller.rb:
---------------------------------
def show
@news = News.find(params[:id])
render_partial ''news''
end
def show_category
@news = NewsCategory.find(params[:id]).news
render_partial ''news'', :collection => @news
end
_news.rhtml:
---------------------------------
<div>
<h1><%=h news.title %> - Kategory: <%= news.news_category.title %></
h1>
<p>
<%= bbcodeize news.content...