fast_jsonapi
fast_jsonapi copied to clipboard
Have conditional link ? similar to conditional attributes.
getting
TypeError ({:if=>#Proc:0x00007fb68de748e8} is not a symbol nor a string)
when trying to use ,
link :sms_url, if: proc { | params| params[:action] == 'sms' }
and I am sending the params through options = {params: {action: 'sms'}}
We do not have conditional links yet. Is this a feature request or a bug report?
@manojmj92 More of a feature request or if there is a workaround
The only work around I found was to just pass a conditional statement in the block that returns null.
Consider the following:
link :approve do |record, params|
approve_comment_path(record) if params && params[:admin]
end
link :deny do |record, params|
deny_comment_path(record) if params && params[:admin]
end
Would return:
{
data: [
{
...snippet
links: [
approve: null,
deny: null
]
}
]
}
I agree that conditional links would be a nice feature.