ruby-on-rails-3

I'm confused: 'rails -v' and 'gem list' show different versions

强颜欢笑 提交于 2020-01-06 01:36:10
问题 I've made a fresh installation of Ruby on Rails on my Windows 7 machine (using RailsInstaller) after a failed attempt to follow Michael Hartl's Ruby on Rails Tutorial (if you're interested, see my previous question pertaining to the said fail). As I thought my previous fail had something to do with my inept attempt at installing different gem versions hoping to replicate requirements laid out in the tutorial, I decided to check the version of rails gem immediately after the install. When I

Michael Hartl's Ruby on Rails Tutorial, toy_app user tour

守給你的承諾、 提交于 2020-01-06 01:29:05
问题 I'm working through Michael Hartl's Ruby on Rails Tutorial and all steps have worked as expected up to the start of section 2.2.1. The first sentence says visiting the root will display the default Rails page. But it doesn't; it shows "hello world" because the tutorial in section 2.1 has us define the root to be application#hello right before deploying to Heroku. If I go to http://localhost:3000/users/, I get an error: ExecJS::ProgramError in Users#index Showing C:/Users/dfretz/dfretz

Fixtures: How to load utf-8 characters and convert to non utf-8 and save into database?

匆匆过客 提交于 2020-01-06 01:16:07
问题 I am new to Rails. I am working on a legacy code which relies on Fixtures to load non UTF8 characters from yml files into database. With rails lastest version, the yml must be utf-8 encoding, meaning that what Fixtures read in will be utf-8 encoding. How to convert the following codes so that it will convert from utf-8 to non-utf8 and load into database (non-utf8 encoding of course). class LoadUsersData < ActiveRecord::Migration def self.up down directory = File.join(File.dirname(__FILE__))

No route matches [POST] “/users/new”

泄露秘密 提交于 2020-01-05 14:02:35
问题 Please help me for resolve this error. Error: No route matches [POST] "/users/new" My code snippets are: views/users/index.html.erb <h1>This is Registration page..</h1> <div class="sign"> <%= button_to "Registration",{:controller => "users", :action => "new",method: :get} %> <%= button_to "Login",action:"login" , method: :get %> </div> config/route.rb Rails.application.routes.draw do root "users#index" get "users/new" => "users#new" get "users/login" => "users#login" #get "users/new" =>

How to delete multiple checked records in rails?

自古美人都是妖i 提交于 2020-01-05 12:56:31
问题 I figured out how to display checkbox for each row. The problem is that I can't find out how to write form_tag and submit tag in order to pass the checked rows parameter to messages_controller with using detele action. and what to write in delete action. Please help me out! My view is <table> <tr> <th>delete</th> <th>ID</th> <th>Read</th> <th>Date</th> <th>Sender</th> <th>Subject</th> </tr> <% @messages.each do |m| %> <tr> <td><%= check_box_tag '', m.id, false, class: 'delete_multiple

Problems getting has_many :x, :through => :y to work in the console

感情迁移 提交于 2020-01-05 12:16:12
问题 Create new Rails app (terminal) rails new hmt cd hmt Generate models, scaffolding, DB schema, etc (terminal) rails g model magazine name rails g model reader name rails g model subscription magazine:references reader:references Make tables based on generated DB schema (terminal) rake db:migrate Check if tables are created ok (terminal) rails c (Rails console) Magazine.column_names Reader.column_names Subscription.column_names Specify relationships in models/ (magazine.rb) class Magazine <

Why does Guard run ALL my RSpec specs on every change?

三世轮回 提交于 2020-01-05 10:27:22
问题 This testing stack is behaving unreliably. Sometimes when I run guard, it performs adequately with the guard-rspec gem and will only run the file that has been changed. At least, if the test fails it will stop with that single modified file. But if that test passes, all bets are off. It will continue to run ALL tests when a single file is changed. On a good-sized application, this is extremely impractical and frustrating to see all tests run every time a file is saved. My Guardfile is as

how to override rails 3 engine models and controllers in the main application?

浪尽此生 提交于 2020-01-05 10:20:49
问题 I want to be able to override models and controllers of my rails 3 engine in the base app. Inspecting $LOAD_PATH, I found engine's 'app/{models,controllers}' there, but I can't explicitly require engine's model or controller file: require 'engine_name/model_name' fails with "no such file" (tried with both namespaced(app/controllers/enginename/*) and plain engine). So, what's the best way to extend engine's models/controllers in rails 3 without copying them to base app? Basically, it's a load

Superclass mismatch for class User (TypeError)?

≡放荡痞女 提交于 2020-01-05 09:34:43
问题 I have trouble with Heroku. I did heroku logs and got a error message: /app/app/models/user.rb:1:in `<top (required)>': superclass mismatch for class User (TypeError) /app/app/models/user.rb:1:in `<top (required)>': superclass mismatch for class User (TypeError) 2013-11-28T03:39:50.220378+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/activesupport- 3.2.11/lib/active_support/dependencies.rb:251:in `require' 2013-11-28T03:39:50.220378+00:00 app[web.1]: from /app/vendor/bundle/ruby/2

Trouble with Paperclip and Ajax with Rails 3.2.8

白昼怎懂夜的黑 提交于 2020-01-05 09:25:09
问题 I am writting an application 100% ajax with rails 3.2.8 Everything was going great until I tried to upload photos of the employees to the employee management module. This is part of my code: At the Controller: class EmpleadosController < ApplicationController respond_to :js before_filter :require_user def index @empleados = Empleado.paginate( page: params[ :page ], joins: [:user,:contacto], select: 'empleados.id as id, empleados.user_id, empleados.contratado_el, empleados.despedido_el,