Я не могу использовать paperclip для загрузки файла. Я следую этой обучающей программыpaperclip file not uploading
http://larsgebhardt.de/parse-xml-with-ruby-on-rails-paperclip-and-nokogiri/
Это то, что я сделал:
route.rb:
resources :users do
resources :rides do
resources :comments
end
resources :challenges do
get "accept"
post 'accept'
end
end
...
validates :gpx, presence: true
rides.rb:
require 'nokogiri'
class Ride < ActiveRecord::Base
belongs_to :user
has_many :comments, dependent: :destroy
has_many :challenges
# Tracksegments
has_many :tracksegments, :dependent => :destroy
has_many :points, :through => :tracksegments
has_attached_file :gpx
create_rides.rb
add_attachment :rides, :gpx
rides/new.html.erb
<h1>New Ride</h1>
<%= form_for [@user,@ride] do |f| %>
<div>
<%= f.label :name, :class => 'control-label' %>
<div>
<%= f.text_field :name, :class => 'text_field' %>
</div>
</div>
<div>
<%= f.label :gpx, :class => 'control-label' %>
<div>
<%= f.file_field :gpx %>
</div>
</div>
<div>
<%= f.submit %>
</div>
<% end %>
<div>
<%= link_to 'Back', user_rides_path %>
</div>
Все делает хорошо, но файл не загружен. Страница застревает из-за текущей проверки, установленной в model.rb. Что не так?
: gpx не был разрешен в моем контроллере –
Рад, что вы смогли заставить его работать! –