ruby-on-rails-3.1

How do you create prepared statements with the mysql2 gem?

╄→гoц情女王★ 提交于 2019-11-30 01:50:17
问题 I've tried using google to answer this seemingly simple question, but to my surprise, it didn't help. I have code in my rails application currently using the 'prepare' method with the mysql gem. On switching to mysql2, this breaks with the error: undefined method `prepare' for #<Mysql2::Client::0....... So I tried looking for a version of the 'prepare' method but this search has been unsuccessful so far. Can anyone help me out with this? Edit: If this isn't possible, could anyone let me know

Rspec Rails 3.1 Integration test. How to send post request headers for mobile, http basic authentication and JSON?

霸气de小男生 提交于 2019-11-30 01:30:45
问题 I have an RSPEC integration test for a Rails 3.1 app that needs to test an api for a mobile client by issuing a POST request with JSON params and a mobile header that needs to use http_basic authentication As the request object is not available in an integration test I'm kinda stuck This is the code I have so far it "successfully posts scores" do # request.env["HTTP_ACCEPT"] = "application/json" #This causes an error as request is nly available in controller tests post "scores", :score => {

How to build task 'assets:precompile'

[亡魂溺海] 提交于 2019-11-30 01:27:25
I'm getting that error on my production server, and can't figure out why. It happens when running this command: bundle exec rake assets:precompile RAILS_ENV=production I'm using Rails 3.1.0.rc6 This is most likely due your config/application.rb not requiring rails/all (the default), but some custom requires. To resolve this, add the following to config/application.rb : require 'sprockets/railtie' I know this is an old post but I thought it might help someone (probably my future self) if I added this to the answers. add to Capfile (or deploy.rb) load 'deploy/assets' add this to application.rb

devise overriding registrations controller - uninitialized constant Users::RegistrationsController

◇◆丶佛笑我妖孽 提交于 2019-11-30 01:19:30
问题 I'm trying to override some the functionality of the default devise registrations controller so that only certain users can create accounts for others. So in a file called registrations_controller.rb under the controllers/users folder I have the following class Users::RegistrationsController < Devise::RegistrationsController before_filter :check_permissions, :only => [:new, :create, :cancel] skip_before_filter :require_no_authentication def check_permissions authorize! :create, resource end

ruby on rails add a column after a specific column name

房东的猫 提交于 2019-11-30 01:15:07
问题 I tried to add a column to a table after a specific column in the table. Here is what I did: rails generate migration add_reaction_id_to_patient_allergies reaction_id: integer :after => 'patient_id' Here is what my migration file looks like: class AddReactionIdToPatientAllergies < ActiveRecord::Migration def change add_column :patient_allergies, :reaction_id, :string add_column :patient_allergies, :integer, :string add_column :patient_allergies, :, :after add_column :patient_allergies, :=,

Rails 3.1 issue with javascript_include_tag in application.html.erb

折月煮酒 提交于 2019-11-30 00:17:04
I've created a clean and simple Rails 3.1 application called demo1. It contains two controllers - hello and goodbye. I get the following error when I try to load http://localhost:3000/say/hello : ActionView::Template::Error ( (in /home/me/dev/ruby/demo1/app/assets/javascripts/say.js.coffee)): 3: <head> 4: <title>Demo1</title> 5: <%= stylesheet_link_tag "application" %> 6: <%= javascript_include_tag "application" %> 7: <%= csrf_meta_tags %> 8: </head> 9: <body> app/views/layouts/application.html.erb:6:in `_app_views_layouts_application_html_erb___558576499_89622220' The problematic line of

What is the value of Compass for Rails 3.1?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-29 23:59:46
I'm trying to decide if I should include Compass when starting a new Rails 3.1 project. I haven't used Compass before. Rails 3.1 now supports SCSS directly. The Rails 3.1 asset pipeline (via sprockets) now compiles stylesheets automatically. And I can use a SCSS version of a CSS framework such as Blueprint directly. What benefits will I get from using Compass with Rails 3.1? Bourbon (by Thoughtbot) is a light alternative to compass that integrates well with rails 3.1. It has the main css3 mixins you get with compass (background-images, box shadow, border radius, gradients...). It also has

How to call a parent app's helper method from a rails 3.1 engine

自古美人都是妖i 提交于 2019-11-29 23:53:02
问题 I'm building a rails engine that uses the "acts as" format to establish relationships with the parent application's User model. module Cornerstone module ActsAsCornerstoneUser extend ActiveSupport::Concern module ClassMethods def acts_as_cornerstone_user(options = {}) #= Associations has_many :cornerstone_discussions #= Options Cornerstone::Config.auth_with << options[:auth_with] if options[:auth_with] Cornerstone::Config.auth_with.flatten! end end module InstanceMethods end end ActiveRecord:

How do I turn off automatic stylesheet/javascript generation on Rails 3.1?

孤者浪人 提交于 2019-11-29 23:41:22
I've got a Rails 3.1 project that I'm working on, but I don't want controller_name.css.sass and controller_name.js.coffee to be generated each time I run rails generate controller controller_name . I could swear I've seen the setting somewhere on the internet, but I can't find it now for the life of me. What is it? Keep in mind that I'm still wanting to use the Asset Pipeline and the CoffeeScript/Sass integration, but I'm organizing those files in my own way. I'm pretty sure the answer is a command line argument, but bonus points for turning it off with a generator setting or a hidden file or

How to use compass with rails 3.1

∥☆過路亽.° 提交于 2019-11-29 22:12:57
I have searched and searched and all I could see was that to use compass with rails 3.1 was to just edit the Gemfile like so: gem 'compass', :git => 'https://github.com/chriseppstein/compass.git', :branch => 'rails31' gem 'sass-rails', "~> 3.1.0.rc" Yes I understand that but what next? Every tutorial I saw said just that, use that certain fork. But I am still having trouble with using compass with rails 3.1. I did this: $ compass init rails . --syntax sass directory ./app/stylesheets/ create ./config/compass.rb create ./app/stylesheets/screen.sass create ./app/stylesheets/print.sass create .