Groups
Groups
Sign in
Groups
Groups
Paperclip Plugin
Conversations
About
Send feedback
Help
using .becomes(class) on STI models prevents attachment from being saves
1 view
Skip to first unread message
Spike
unread,
Jul 21, 2009, 12:25:51 AM
7/21/09
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Paperclip Plugin
Hi there, quite an edge case, but I have a STI set of models (quiz
questions). The attachment is defined on the parent class.
If you do this:
@question = @quiz.questions.build(params[:question]).becomes(params
[:question][:question_type].constantize)
it will still save the file details to the database but won't actually
save the file.
To work around it you just build the question and then set the
attributes later:
@question = @quiz.questions.build.becomes(params[:question]
[:question_type].constantize)
@question.attributes = params[:quiz_set_quiz_question]
but it's be nice if it actually worked. I presume paperclip is loosing
track of the file during the class changing process.
Cheers,
Brendon
Reply all
Reply to author
Forward
0 new messages