Frage

I generated a new model called Comment.

rails g model Comment user_id:integer content:text
rake db:migrate

Then I create a simple partial view, that I intend to call from another controller/view.

enter image description here

Inside of a Product show view:

.comments
  h3
    | Questions and Answers:
    small for #{@product.name}

    = render 'comments/new'

Missing partial comments/new with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :raw, :ruby, :jbuilder, :slim, :coffee]}. Searched in: * "/Users/sergiotapia/Documents/Work/foobar/app/views"

I stopped and started the Rails application and it's still refusing to detect the partial. Am I overlooking something?

I would prefer not to move the comment form to the Products folder.

War es hilfreich?

Lösung

Incorrect File Extension

Rename partial file to _new.html.slim. Currently html is misspelt as hmtl.

Andere Tipps

Try this out:

2.2.4 Rendering an Arbitrary File

The render method can also use a view that's entirely outside of your application (perhaps you're sharing views between two Rails applications):

render "/u/apps/warehouse_app/current/app/views/products/show"

Rails determines that this is a file render because of the leading slash character. To be explicit, you can use the :file option (which was required on Rails 2.2 and earlier):

render file:"/u/apps/warehouse_app/current/app/views/products/show"

The :file option takes an absolute file-system path. Of course, you need to have rights to the view that you're using to render the content.

Taken from here: http://guides.rubyonrails.org/layouts_and_rendering.html

EDIT: Oh sure, the file name is not correct, didn't see that. ;) See Kirti Thorat's answer.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top