upmin / upmin-admin-ruby

Framework for creating powerful admin backends with minimal effort in Ruby on Rails.
MIT License
755 stars 66 forks source link

Accessing <model>_path in custom model_view #94

Closed ColinTheRobot closed 9 years ago

ColinTheRobot commented 9 years ago

Context

I'm using paperclip/aws-sdk to upload images for specific models.

Upmin doesn't know how to deal with those fields in the way that paperclip needs it to so I'm building out my own form to upload files in the custom model view partial.

_app/view/upmin/partials/models/topic.html.erb

  <%= form_for "#{topic.model}", url:(topic_path("#{topic.model}")) do |f| %>
      <%= f.label :cover_image %>
      <%= f.file_field :cover_image %>
      <%= f.submit "new cover image" %>
    <% end %>

Question

So to access the Topic object it has to be inside of a string and interpolated, as you can see above, but what's throwing me is how to then direct the action back to the topics_controller in the host app?

Rails throws the error undefined methodtopic_path' for #<#Class:0x007f88d2d280b8:0x007f88d289a820>`

joncalhoun commented 9 years ago

See https://github.com/upmin/upmin-admin-ruby/wiki/Accessing-your-Application-Routes-inside-Upmin-Admin