ruby-on-rails-3.2

Error, Ruby on Rails: Encoding::UndefinedConversionError in CoursesController#attachment “\xFF” from ASCII-8BIT to UTF-8

好久不见. 提交于 2019-12-18 11:50:38
问题 I'd like to make a simple file uploader using tag_form on Rails 3.2.8. But when I try to submit a image file, I get an error saying Error Message (when I try to submit a image file) Encoding::UndefinedConversionError in CoursesController#attachment "\xFF" from ASCII-8BIT to UTF-8 I'd appreciate it if you help me with this problem. Here's my codes. app/view/show.html.erb <%= form_tag(attachment_course_path, :action=>'attachment', :multipart => true) do %> <div class="field"> <%= label_tag

Rails: How to filter results?

人走茶凉 提交于 2019-12-18 06:59:54
问题 In the index action of my Users controller, I am able to capture all users belonging to the same city as the current_user in an ActiveRecord::Relation object @users . In my view I am able to iterate through @users and display the results. What I'd like to do is give the current_user further options to filter the results. I want to add a form and filter button in the view, which will allow the current_user to select filters, such as: Minimum Age and Maximum Age (Drop Down) Religion (Drop down

Incomplete response body being returned from Rails 3 app with RABL

 ̄綄美尐妖づ 提交于 2019-12-18 06:16:33
问题 I've built a JSON API using Rails 3 and RABL The API works well but on particular requests only part of the data is returned - the rest of the JSON is cut off. Since the JSON is therefore invalid, the mobile app which relies on the API is crashing. Can anybody think of why the body is cut off at a certain size and point me in the right direction to resolve the issue? Thanks 回答1: So I was able to track this issue down to Passenger Long story short I fixed it by setting passenger_buffer

Rails: “t.references” not working when creating index

江枫思渺然 提交于 2019-12-18 05:46:35
问题 class CreateBallots < ActiveRecord::Migration def change create_table :ballots do |t| t.references :user t.references :score t.references :election t.string :key t.timestamps end add_index :ballots, :user add_index :ballots, :score add_index :ballots, :election end end results in: SQLite3::SQLException: table ballots has no column named user: CREATE INDEX "index_ballots_on_user" ON "ballots" ("user")/home/muhd/awesomevote/db/migrate/20130624024349_create_ballots.rb:10:in `change' I thought t

rails assets pipeline “Cannot allocate memory - nodejs”

耗尽温柔 提交于 2019-12-17 23:26:42
问题 we've just upgraded to Rails 3.2.5 from Rails 3.0.7 and using the assets-pipeline compilation on the fly for the staging server, but some times we face this exception ! Showing /var/rails/appname/app/views/common/_my_partial.html.haml where line # raised: Cannot allocate memory - nodejs /tmp/execjs20120613-17090-thoc8f.js 2>&1 Extracted source (around line #): Trace of template inclusion: app/views/layouts/application.html.haml Although nothing fancy or huge memory allocations is done in the

Seeding users with Devise in Ruby on Rails

守給你的承諾、 提交于 2019-12-17 23:10:16
问题 In my development and test environments, I want to seed the database with a bunch of users. I'm using Ruby on Rails v3.2.8 and the latest Devise. So I added this line in my db/seeds.rb file: User.create(email: 'test@example.com', encrypted_password: '#$taawktljasktlw4aaglj') However, when I run rake db:setup , I get the following error: rake aborted! Can't mass-assign protected attributes: encrypted_password What is the proper way to seed users? 回答1: You have to do like this: user = User.new

How to debug a rails (3.2) app started by foreman?

可紊 提交于 2019-12-17 23:08:26
问题 I am trying to use foreman to start my rails app. Unfortunately I have difficulties connecting my IDE for debugging. I read here about using Debugger.wait_connection = true Debugger.start_remote to start a remote debugging session, but that does not really work out. Question: Is there a way to debug a rails (3.2) app started by foreman? If so, what is the approach? 回答1: If you use several workers with full rails environment you could use the following initializer: # Enabled debugger with

Rails console 'y' helper returns NameError rather than yaml-formatting output

本小妞迷上赌 提交于 2019-12-17 22:54:07
问题 I'm trying to use y object in Rails 3.2.6/Ruby 1.9.3 console to get nicely formatted yaml output for an ActiveRecord object, but for some reason it isn't working for me. I've used it in the past, but somewhere along the way it broke. I get the following output when I try: NameError: undefined local variable or method `yaml' for main:Object 回答1: The y method is actually an extension to the Kernel object put in place by the Syck YAML parser/emitter. Here are the last few lines of lib/ruby/1.9.1

Editing Users With Devise and Omniauth

谁说胖子不能爱 提交于 2019-12-17 22:22:34
问题 I'm working through the Railscast on implementing Devise and OmniAuth (along with the Devise documentation) -- currently, I've got a site going where visitors can sign up using their facebook accounts or by filling out a form. I'm running into trouble when users that sign up via OmniAuth try to edit their profiles, though. Devise looks for the user's current password when they submit changes to their profiles, but those that logged in with facebook don't know their passwords (they're set

Model.reset_column_information does not reload columns in rails migration

二次信任 提交于 2019-12-17 21:56:16
问题 I'm using Rails 3.2 and have a migration that contains the code: add_column :users, :gift_aid, :integer, :default => 2 # reset columns User.reset_column_information ... code here to load legacy data from sqlite3 database ... # now create a user with the loaded column data user = User.create( ...other cols..., :gift_aid => migrated_gift_aid_column_data, ...other cols... ) and I get unknown attribute: gift_aid when running the migration. User.column_names shows the same list before and after