ruby-on-rails-3.1

Deploy Rails Application on EC2

我与影子孤独终老i 提交于 2019-11-26 19:54:54
问题 For the past week, I've been playing with the Rubber gem and can't seem to get it to work. I've decided it would be easier just to manually set up my EC2 instance. The problem is that I don't know how. Google hasn't been much help for a newb either. Any suggestions? It really is appreciated. 回答1: Sure. Create a AWS account. Decided what region you want to be in. Lots of things go into this decision, but worry about it later and just do a cheap one like Oregon or East. Make sure you are in the

Subqueries in activerecord

蹲街弑〆低调 提交于 2019-11-26 19:44:30
With SQL I can easily do sub-queries like this User.where(:id => Account.where(..).select(:user_id)) This produces: SELECT * FROM users WHERE id IN (SELECT user_id FROM accounts WHERE ..) How can I do this using rails' 3 activerecord/ arel/ meta_where? I do need/ want real subqueries, no ruby workarounds (using several queries). Rails now does this by default :) Message.where(user_id: Profile.select("user_id").where(gender: 'm')) will produce the following SQL SELECT "messages".* FROM "messages" WHERE "messages"."user_id" IN (SELECT user_id FROM "profiles" WHERE "profiles"."gender" = 'm') (the

rails - “WARNING: Can't verify CSRF token authenticity” for json devise requests

一世执手 提交于 2019-11-26 19:19:47
How can I retrieve the CSRF token to pass with a JSON request? I know that for security reasons Rails is checking the CSRF token on all the request types (including JSON/XML). I could put in my controller skip_before_filter :verify_authenticity_token , but I would lose the CRSF protection (not advisable :-) ). This similar (still not accepted) answer suggests to Retrieve the token with <%= form_authenticity_token %> The question is how? Do I need to do a first call to any of my pages to retrieve the token and then do my real authentication with Devise? Or it is an information one-off that I

Rails 3.1: Engine vs. Mountable App

淺唱寂寞╮ 提交于 2019-11-26 19:14:52
Can someone help me understand the differences between a Rails Engine and a Mountable app? In Rails 3.1, you can create either one with the "rails new plugin _ __ " command. rails plugin new forum --full # Engine rails plugin new forum --mountable # Mountable App When would you want to use one versus the other? I know you can package an Engine as a gem, for one. Is that not the case for Mountable Apps? What other differences are there? astjohn I have noticed the following: Full Engine With a full engine, the parent application inherits the routes from the engine. It is not necessary to specify

Speed up assets:precompile with Rails 3.1/3.2 Capistrano deployment

故事扮演 提交于 2019-11-26 18:43:26
问题 My deployments are slow, they take at least 3 minutes. The slow Capistrano task during deploy is assets:precompile. This takes probably 99% of the total deploy time. How can I speed this up? Should I precompile my assets on my local machine and add them to my git repo? Edit: Adding config.assets.initialize_on_precompile = false to my application.rb file dropped the precompile time with half a minute, but it is still slow. 回答1: The idea is that if you don't change your assets you don't need to

Changing a column type to longer strings in rails

不问归期 提交于 2019-11-26 18:01:38
问题 At the first migration, I declared on a column content to be string Activerecord made it to be string(255) according to annotate gem. After I push the app to heroku, which uses postgres, if I enter in the form in content a string longer than 255 I get the error PGError: ERROR: value too long for type character varying(255) Problem is I need that content to contain a string that is extremely long perhaps (free text, could be thousands of chars) What variable (is string is not appropriate for

Using @font-face with Rails 3.1 app?

房东的猫 提交于 2019-11-26 17:58:12
问题 I'm having trouble using the following @font-face declaration to work with my Rails 3.1 app. I put the fonts in the Asset Pipeline in its own folder called "Fonts" alongside images and stylesheets and javascripts Here is the declaration I used (generated by Font Squirrel.) @font-face { font-family: 'ChunkFiveRegular'; src: url('Chunkfive-webfont.eot'); src: url('Chunkfive-webfont.eot?#iefix') format('embedded-opentype'), url('Chunkfive-webfont.woff') format('woff'), url('Chunkfive-webfont.ttf

Rails 3.1 remote requests submitting twice

不问归期 提交于 2019-11-26 16:09:26
问题 I developed a Rails 3.1 application that consists of a 100% Ajax CRUD forms to input users and customers. I created two separate models, controllers, views etc. The views for each model contain jquery files for create edit update and destroy. The problem is when I perform any operation that performs a remote operation, it is called twice. I can confirm this happening in console view in firebug as well as output in WEBrick output. Can anyone assist in tracking down what happened here? What

Rails 3.1 and jquery-ui assets

泪湿孤枕 提交于 2019-11-26 15:03:42
问题 This was asked in another question, but none of the solutions appear to work for me in 3.1rc1. I'm trying to use the new assets stuff in rails 3.1 - I have the files: ./vendor/assets/stylesheets/jquery-ui-1.8.13.custom.css ./vendor/assets/javascripts/jquery-ui-1.8.13.custom.min.js I then added: //= require jquery-ui to app/assets/javascripts/application.js *= require jquery-ui to app/assets/stylesheets/application.css The jquery-ui javascript file loads just fine, but the css file says:

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

谁说胖子不能爱 提交于 2019-11-26 14:37:30
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.Company).group(:user_id).all Craig Ringer If user_id is the PRIMARY KEY then you need to upgrade PostgreSQL; newer