Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

Naomi Freeman
STAFF
Naomi Freeman
Treehouse Guest Teacher

Updating to strong params

Hi everyone,

I am doing treebook in rails 4.

I've had no problem changing attr_accessible to strong params, moving it into the controller instead of the model.

I'm in the advanced social features, upload an image, near the end.

My attachment won't show up.

It did throw some errors at one point, but is quiet now.

The attachment button is there.

Anyways - I wonder if it might be that my attr_accessible/strong params is configured incorrectly.

In the video/project files it says to do this in the statuses controller:

def update @status = current_user.statuses.find(params[:id]) @document = @status.document if params[:status] && params[:status].has_key?(:user_id) params[:status].delete(:user_id) end respond_to do |format| if @status.update_attributes(params[:status]) && @document && @document.update_attributes(params[:status][:document_attributes]) format.html { redirect_to @status, notice: 'Status was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @status.errors, status: :unprocessable_entity } end end end

What I'm struggling with is where it has that double params - @document.update_attributes(params[:status][:document_attributes])

One of those params would be @document.update_attributes(status_params)

Any idea how I do it properly to have both of them? My app isn't throwing an error or anything, no matter which way round I put brackets or anything, so I've got nothing to go on. It just won't show the attachment.

Thanks!