Rails Carrierwave and Simple Form

梦想与她 提交于 2019-12-12 06:19:51

问题


I have a rails 4 app that I use with simple form and carrierwave.

In my profile view, I have a form that includes a request for users to nominate their university, as follows:

<%= f.collection_select :university, University.all, :id, :name %>

In my university model, I create universities and add their associated logos:

{ :class => 'question-project' }, placeholder: 'Your uni name', :input_html => {:style=> 'width: 650px', class: 'response-project'} %>
  <%= f.label :'Your university logo', :label_html => { :class => 'question-project' }, placeholder: 'Insert JPG image', :input_html => {:style=> 'width: 650px', class: 'response-project'}%>

  <%= f.file_field :logo %>

I have an avatar_uploader which has a logo version to resize the image of the university logo. I call that version: logo.

I use that in my profile view to show the university and the university logo as follows:

            <%= image_tag (@profile.university.logo.logo) %>

The first logo is a reference to the logo in the university table and the second is to the name of the avatar uploader version.

I get an error when I test this that says:

undefined method `logo' for nil:NilClass

Does anyone know what this means?

Thank you

来源:https://stackoverflow.com/questions/29311661/rails-carrierwave-and-simple-form

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!