I have question model with has many relationship of question_options.
class Question < ActiveRecord::Base
#relationship
belongs_to :user
has_many :question_options, :dependent => :destroy,:conditions => "is_deactivated is FALSE"
Question option
class QuestionOption < ActiveRecord::Base
attr_accessible :question_id,:option,:order,:is_other,:is_deactivated
belongs_to :question
In my question_detail rabl I have
object @question
attributes :id, :status
child :question_options do
attributes :question_id,:option,:order,:is_other
end
Here I want to respond only the question_option which has is_other = false
like the below....
object @question
attributes :id, :status
child :question_options do
attributes :question_id,:option,:order,:is_other = true
end
How do I check a condition in rable that?
One easy way to do this is to use if
if
option onattributes
, for example:Also check out the section on conditions.