ruby-on-rails-3.1

PostgreSQL -must appear in the GROUP BY clause or be used in an aggregate function

允我心安 提交于 2019-11-26 03:58:11
问题 I am getting this error in the pg production mode, but its working fine in sqlite3 development mode. ActiveRecord::StatementInvalid in ManagementController#index PG::Error: ERROR: column \"estates.id\" must appear in the GROUP BY clause or be used in an aggregate function LINE 1: SELECT \"estates\".* FROM \"estates\" WHERE \"estates\".\"Mgmt\" = ... ^ : SELECT \"estates\".* FROM \"estates\" WHERE \"estates\".\"Mgmt\" = \'Mazzey\' GROUP BY user_id @myestate = Estate.where(:Mgmt => current_user

Using Rails 3.1 assets pipeline to conditionally use certain css

不羁岁月 提交于 2019-11-26 03:46:25
问题 I’m in the process of building my first solo Rails app using Rails 3.1.rc5. My problem is that I want to have my site render the various CSS files conditionally. I’m using Blueprint CSS and I’m trying to have sprockets/rails render screen.css most of the time, print.css only when printing, and ie.css only when the site is accessed from Internet Explorer. Unfortunately, the default *= require_tree command in the application.css manifest includes everything in the assets/stylesheets directory

Rails 3.1 asset pipeline: how to load controller-specific scripts?

大憨熊 提交于 2019-11-26 03:01:43
问题 If I generate a new controller in Rails 3.1, also a javascript file with the name of the controller will added automatically. Firstly, I thought this javascript file will used only, when the related controller is called. By default there is the instruction //= require_tree . in the application.js -file, that include every javascript file on it\'s tree. How could I load only the controller specific script? 回答1: To load only the necessary name_of_the_js_file.js file: remove the //=require_tree

Using Rails 3.1, where do you put your “page specific” JavaScript code?

可紊 提交于 2019-11-26 01:26:33
问题 To my understanding, all of your JavaScript gets merged into 1 file. Rails does this by default when it adds //= require_tree . to the bottom of your application.js manifest file. This sounds like a real life-saver, but I am a little concerned about page-specific JavaScript code. Does this code get executed on every page? The last thing I want is for all of my objects to be instantiated for every page when they are only needed on 1 page. Also, isn\'t there potential for code that clashes too?

ExecJS and could not find a JavaScript runtime

不羁的心 提交于 2019-11-26 00:49:33
问题 I\'m trying to use the Mongoid / Devise Rails 3.1 template ( Mongoid and Devise ), and I keep getting an error stating ExecJS cannot find a JavaScript runtime. Fair enough when I didn\'t have any installed, but I\'ve tried installing Node.js, Mustang and the Ruby Racer, but nothing is working. I could not find a JavaScript runtime. See sstephenson/ExecJS (GitHub) for a list of available runtimes ( ExecJS::RuntimeUnavailable ). What do I need to do to get this working? 回答1: Ubuntu Users I'm on