1
current_user
핀을 클릭하면 어떻게 이미지가 current_user
에 저장 될 수 있습니까?고정 된 이미지 [GET]과 경로가 일치하지 않습니다.
버튼 :
<%= simple_form_for(@inspiration) do |f| %>
<%= f.hidden_field :image_file_name, value: inspiration.image_file_name %>
<%= f.hidden_field :image_content_type, value: inspiration.image_content_type %>
<%= f.hidden_field :image_file_size, value: inspiration.image_file_size %>
<%= button_tag(type: 'submit', class: "btn btn-primary") do %>
<span class="glyphicon glyphicon-pushpin"></span>
<% end %>
<% end %>
출력 : No route matches [GET] "/system/inspirations/images/000/000/002/medium/choose-optimism.png"
pry(main)> Inspiration.first
id: 1,
user_id: 1,
image_file_name: "choose-optimism.png",
image_content_type: "image/png",
image_file_size: 230082,
pry(main)> Inspiration.last
id: 2, # Creating the issue of the route error & image not rendering
user_id: 2,
image_file_name: "choose-optimism.png",
image_content_type: "image/png",
image_file_size: 230082,
id
오류를주는 고정 된 이미지에 대한 다른
작업 이미지 001
있습니다
/system/inspirations/images/000/000/001/medium/choose-optimism.png?1478840469
그래서 다른 ID를 통과,하지만 같은 이미지를 계속 사용할 수 있습니다이 문제를 해결하는 가장 좋은 방법은 무엇입니까?
컨트롤러
@inspirations = @user.inspirations # Renders Images with Pin Overlayed
@inspiration = current_user.inspirations.build # For the Button
def create
@inspiration = current_user.inspirations.build(inspiration_params)
@inspiration.save
respond_modal_with @inspiration
end
모델에서
컨트롤러 작업을위한 코드를 게시 할 수 있습니까? –
@MuradYusufov 완료! –
사용자 정의 보간을 정의해야한다고 생각합니다. 잠깐, 대답을 작 성하려고합니다. –