RailsCasts Pro episodes are now free!

Learn more or hide this

Immense Networks's Profile

GitHub User: immensenet

Site: http://www.immense.net

Comments by Immense Networks

Avatar

Hmm. This worked, but the image came out with severe decrease in quality. But thanks very much for sending me in the right direction.

Avatar

I will definitely look into it. I seem to remember prawn was more of a pdf generator than converter, but I'll take a second look. :)

Avatar

There's a link to the show notes to the left of the 'Comments' button.

Avatar

Awesome stuff, Ryan, as usual. Btw, does anyone know of an easy way to manipulate pdfs, specifically to create a jpg of a pdf? I tried with minimagick with no success.

Avatar

I just came across this issue. It is as you expected: object.send(association) does not work the same way for has_one as it does for has_many. To get around this, I changed the link_to_add_fields helper as follows:

ruby
  def link_to_add_fields(name, f, association)
    new_object = f.object.class.reflect_on_association(association).klass.new
    id = new_object.object_id
    fields = f.fields_for(association, new_object, child_index: id) do |builder|
      render(association.to_s.pluralize + "/fields", f: builder)
    end
    link_to(name, '#', class: "add_fields", data: {id: id, fields: fields.gsub("\n", "")})
  end

Basically, I changed f.object.send(association).klass to f.object.class.reflect_on_association(association).klass and, since I use users/_fields.html.erb instead of user_fields.html.erb, I also changed the render line. Hope this helps, if you're still having that problem. If not, hope this helps some other lost soul of the future.

-Christian B.