Default_url in Paperclip Broke with Asset Pipeline Upgrade
:default_url => ActionController::Base.helpers.asset_path(‘missing_:style.png’) Then put the default images in app/assets/images/
:default_url => ActionController::Base.helpers.asset_path(‘missing_:style.png’) Then put the default images in app/assets/images/
Nested attributes appear to work fine for a belongs_to association as of Rails 4. It might have been changed in an earlier version of Rails, but I tested in 4.0.4 and it definitely works as expected.
When Excel opens the CSV file it just assumes an “iso-8859-1” character encoding. I guess it doesn’t even know about the encoding information you send along within your HTTP reply. That’s why setting this to UTF-8 doesn’t work. So in order to export your CSV file for Excel in Rails you could do this: send_data … Read more
Ordering by ID is not guaranteed by default. It’s up to the database how a non-ordered query gets ordered (typically it’s unspecified). If you want your results to be ordered, you need to specify an explicit order with order, as you’ve done: Model.order(id: :asc) Note also that ordering by id should only be done if … Read more
a. Form <%= form_for :file_upload, :html => {:multipart => true} do |f| %> <%= f.file_field :my_file %> <%= f.submit “Upload” %> <% end %> b. controller def file_upload require ‘fileutils’ tmp = params[:file_upload][:my_file].tempfile file = File.join(“public”, params[:file_upload][:my_file].original_filename) FileUtils.cp tmp.path, file … # YOUR PARSING JOB FileUtils.rm file end But you can parse just tempfile, so … Read more
The mentioned line on Devise’s Controller makes sense in general cases: a logged in user can’t sign up. As you’re on a case where only an admin can create a user, I would suggest that you don’t use Devise’s controller on Registerable module and write your own controller with your own rules. You can write … Read more
To create a polymorphic has_many :through, you must first create your models. We will use’Article,’ ‘Category,’ and ‘Tag’ where ‘Tag’ is the join-model and Article is one of many objects which can be “tagged” with a category. First you create your ‘Article’ and ‘Category’ models. These are basic models which do not need any special … Read more
Rails 3: In application.rb, remove the require ‘rails/all’ line and instead add these lines: require “action_controller/railtie” require “action_mailer/railtie” require “active_resource/railtie” require “rails/test_unit/railtie” require “sprockets/railtie” Also see Remove ActiveRecord in Rails 3 and look into the Active Model railscast Rails 3.2.x: You’ll also need to remove/comment out this line in application.rb config.active_record.whitelist_attributes = true And remove/comment … Read more
Since rails 4.1.x, if you want to rename your application, the only two files you need to modify are config/application.rb: require File.expand_path(‘../boot’, __FILE__) require ‘rails/all’ # Require the gems listed in Gemfile, including any gems # you’ve limited to :test, :development, or :production. Bundler.require(*Rails.groups) module YourApplicationName # <– rename it here class Application < Rails::Application … Read more
Had the absolutely same issue on Windows 7 x64 with Ruby 2.0.0 and DevKit 4.7. The following steps helped me. gem uninstall mysql2 Download last MySQL connector from http://cdn.mysql.com/Downloads/Connector-C/mysql-connector-c-noinstall-6.0.2-win32.zip Extract it to C:\connector-6.0.2 gem install mysql2 –platform=ruby — ‘–with-mysql-lib=”C:\connector-6.0.2\lib” –with-mysql-include=”C:\connector-6.0.2\include” –with-mysql-dir=”C:\connector-6.0.2″‘ Or even shorter: gem install mysql2 –platform=ruby — –with-opt-dir=”C:\connector-6.0.2″