ruby-on-rails-3.1

Install the mysql2 gem for a specific mysql client version?

送分小仙女□ 提交于 2019-12-19 09:16:00
问题 I'm trying to use the mysql2 gem with rails 3.1.0.rc6, but I'm having some problem with my mysql client. I'm getting this message when trying to start my server. Incorrect MySQL client library version! This gem was compiled for 5.1.53 but the client library is 5.5.14. (RuntimeError) How do I compile/install mysql2 so that is can use mysql 5.5.14? I've tried using gem pristine mysql2 without success. 回答1: The problem here was that the MySQL2 gem was compiled for the MySQL version installed by

Image showing as blank in Rails 3.1 on Production (Heroku)

六眼飞鱼酱① 提交于 2019-12-19 06:16:36
问题 I recently updated my Rails to 3.1. Here's a part where I added: <%= asset_path('logo_symbol.png') %> This renders /assets/logo_symbol.png which works perfectly fine in development environment. However, when i push the code to production on heroku, it shows a broken image, with the url: assets/logo_symbol-135ddc8db2c9b59f032bed7db520137a.png . I am guessing the new name is for the reason of some optimization. It is however interesting to note that when I go to the assets/logo_symbol

Rails 3.1 assets has no fingerprint in production

一世执手 提交于 2019-12-19 05:59:21
问题 Just started to adapted to rails 3.1, I started to write coffeescript and sass and everything works fine in development. When I run the server in production, I only get: <link href="/stylesheets/application.css" media="screen" rel="stylesheet" type="text/css" /> <script src="/javascripts/application.js" type="text/javascript"></script> in the source code of the page, there's no hashcode generated and both assets has routing errors: Routing Error No route matches [GET] "/stylesheets

Rails 3.1 on Ubuntu 11.10 under VirtualBox very slow

坚强是说给别人听的谎言 提交于 2019-12-19 03:55:10
问题 I have VirtualBox with Ubuntu 11.10 on Windows7. I run Rails 3.1 on webrick (rails s) and go to VirtualBox's IP adress (192.168.2.xxx:3000) from browser on Windows. At this moment I face troubles - page loads very very slowly, on Rails console i see how slowly it responses files (css, js, images): up to 5 seconds for each! But: if I go 0.0.0.0:3000 inside Ubuntu - it works perfect. Where is the problem? Where to look for a solution? 回答1: As mentioned above, it appears this is a duplicate of

ActiveRecord::StatementInvalid: PG::Error: ERROR: null value in column “id” violates not-null constraint

时光怂恿深爱的人放手 提交于 2019-12-19 02:38:26
问题 I am getting the following error frequently in my application. If I restart my rails application this error will not appear for some time. Rails - 3.1.3 Ruby - 1.9.3 ActiveRecord::StatementInvalid: PG::Error: ERROR: null value in column "id" violates not-null constraint Directory.create(:name=>"name",:alias_name=>"name",:site_id=>2,:type=>"Directory") (0.3ms) BEGIN SQL (0.8ms) INSERT INTO "databases" ("alias_name", "created_at", "created_by", "id", "name", "site_id", "type", "updated_at",

“ActionView::Template::Error ( isn't precompiled)” raised on “image_tag nil”

主宰稳场 提交于 2019-12-18 21:54:35
问题 If I don't handle view correctly, Production environment show 500. <%= image_tag post.user.image_url %> This could be <%= image_tag post.user.image_url if post.user && post.user.image_url %> but I am little careless and forgot this issue several times. How can I prevent this? How can I use <%= image_tag nil %> in production environment without raising 500? 回答1: image_tag must have a source, Rails can do nothing with it, but raise an exception. You can write a helper like this: module

“ActionView::Template::Error ( isn't precompiled)” raised on “image_tag nil”

一世执手 提交于 2019-12-18 21:53:59
问题 If I don't handle view correctly, Production environment show 500. <%= image_tag post.user.image_url %> This could be <%= image_tag post.user.image_url if post.user && post.user.image_url %> but I am little careless and forgot this issue several times. How can I prevent this? How can I use <%= image_tag nil %> in production environment without raising 500? 回答1: image_tag must have a source, Rails can do nothing with it, but raise an exception. You can write a helper like this: module

Using Rails 3.1 :as => :admin for updating attributes protected by attr_accessible

懵懂的女人 提交于 2019-12-18 19:37:14
问题 After reading about attr_accessible in the Rails 3.1 API, I see that there is an as :admin option in there. I would like to know two things. If the user has an admin flag, how do does my controller tell my model that the user is an admin. If the user is an owner, can i specify :as => owner in my model, and once again how does my controller inform my model they are the owner of an item. 回答1: There is no built-in integration with models; you pass in the role in the assign_attributes call:

Active Admin authentication conflicting with User authentication

烈酒焚心 提交于 2019-12-18 15:09:01
问题 Active Admin is a gem used for having an admin dashboard in your application. It uses Devise for logging in users and creates a separate admin_user model for the admins. My application already uses devise and has its users as the user model. Ever since I started using the active admin gem, in my routes file the following line keeps resolving to home#index and not users#dashboard even when my user is logged in. This used to work fine earlier where logged in users were taken to users#dashboard

Library not loaded: /usr/local/lib/libpq.5.4.dylib

梦想与她 提交于 2019-12-18 13:53:07
问题 I am working on a rails app. Installed Postgresql using postgresql-9.1.2-1-osx.dmg Installed pg gem. Then when I executed rake db:create getting the following error - dlopen(/Users/sathishvc/.rvm/gems/ruby-1.9.3-head@knome-vivacious/gems/pg-0.12.2/lib/pg_ext.bundle, 9): Library not loaded: /usr/local/lib/libpq.5.4.dylib Checked if /usr/local/lib/libpq.5.4.dylib exists or not. It does not. So, it should be existing somewhere else in the system or I do not know, if I need to install any other