controller.rb
if @object.save
Post.method_name(@object)
end
post.rb
def self.method_name(object)
post_id = 1
p = Post.new
p.post_id = post_id
p.save
end
When Post.method_name(@object) is executed i cant see a new post added into the table even though i cant see any errors either…
Solution:
i was getting the following error
when i used
p.save!due to
validates :post_type, :presence => true, :inclusion=> { :in => @allowed_post_types }so when i added the post type i was using into the array of
@allowed_post_typesthe problem was resolved