Search code examples
ruby-on-railsajaxformatlink-to

ActionController::UnknownFormat in Controller ( #index)


I have a link_to calling my #index. In this method lies a respond_to for a format.js so I can initiate some Ajax. Things is, when I look at the console I get an error 500 because of a "ActionController::UnknownFormat"

I have tested out differents solutions from older posts, but I can't figure out what I'm missing.

controler :

def index
 respond_to do |format|
  format.js { render partial: 'private/messages/load_more_messages' }
 end
end

view :

<%= link_to "Load messages", private_messages_path(:conversation_id => conversation.id), remote: true %>

Does anyone have any thoughts on this ? It's supposed to be a text book case, but I've been hitting my heads against a brick wall with this one.


Solution

  • Well, after going around testing a wide range of ideas, I came back to my original thought and it worked perfectly. I don't know what went wrong the first time but now it is perfect.