ruby-on-rails-3.1

attr_accessor not accessible in accept_nested_attributes_for

夙愿已清 提交于 2019-12-08 18:11:43
问题 On my payments page there are certain variables such as card_number that I want to pass from the View to the Model but I do not want to store them in the db. I can usually easily achieve this by simply using attr_accessor but in this case the model is being passed in params through accepts_nested_attributes_for and for some reason the params are not being passed through: in User.rb i have has_many :credit_cards accepts_nested_attributes_for :credit_cards in the view file i have a nested form

Rails 3.1 using images under app/assets/images/subdirectory

爱⌒轻易说出口 提交于 2019-12-08 17:38:11
问题 In my Rails 3.1 app, I have images stored under app/assets/images/jquery_ui/ . I don't know how to access these in my CSS. /assets/image_name.png and /assets/jquery_ui/image_name.png do not work. 回答1: Seems like /assets/jquery_ui/image_name.png should work, See the answers here. 回答2: If you just added some images to assets and it still doesn't work... you will need to restart your server (/WEBrick). 来源: https://stackoverflow.com/questions/6701010/rails-3-1-using-images-under-app-assets-images

Roo spreadsheet uploading OLE2 signature is invalid

对着背影说爱祢 提交于 2019-12-08 17:07:35
问题 Right so I've checked out Roo. Great gem and all and have a really basic application that doesn't have no models. And basic controller, class and view and I can't seem to get a spreadsheet to upload as I am getting OLE2 signature is invalid error. I have the following basic setup Controller class SpreadsheetServiceController < ApplicationController def new end def create parser = SpreadsheetTagService.new(params[:spreadsheet][:file]) respond_to do |format| format.all {render :json => 'Done'}

How can I use i18n for my error pages in Rails 3?

别等时光非礼了梦想. 提交于 2019-12-08 16:55:02
问题 I need use the I18n api on my public/404.html page. If I add to 404.html page: <%= t('.page_were_looking') %> I get an error message like: Cannot use t('.page_were_looking') shortcut because path is not available How can I use the I18n feature to this page? 回答1: Rails supports multilinguality by serving up error pages with a path like public/500.de.html , where de is the locale. It makes no sense, to use i18n for that case when Rails itself is fundamentally broken. If Rails is that much

Error in Rails 3.1 using js jQuery - “Template is missing”

懵懂的女人 提交于 2019-12-08 14:41:34
I created app according to this post http://stjhimy.com/posts/7-creating-a-100-ajax-crud-using-rails-3-and-unobtrusive-javascript , but get an error: Missing template posts/create, application/create with {:handlers=>[:erb, :builder, :coffee, :haml], :formats=>[:html], :locale=>[:en, :en]}. Searched in: * "/home/ember/Projects/test_app/app/views" Maybe in Rails 3.1 actions render something by default. Besides, there no format js (:formats=>[:html]). But i can`t find any about this. When i doing like this: respond_to do |format| format.js {render :content_type => 'text/javascript'} end or

Get Content Type of Request

喜欢而已 提交于 2019-12-08 14:32:25
问题 To find the incoming content type, docs say: request.headers["Content-Type"] # => "text/plain" But I found by trial-and-error, that doesn't work, but this does: request.headers["CONTENT_TYPE"]=='application/json' So what's the most robust+portable way to do it? 回答1: I would usually go for request.format and request.content_type for reading these header fields. EDIT : found a bit more on this that might help: https://stackoverflow.com/a/1595453/624590 回答2: You don't need to parse the content

Algorithm advice — calculating related stores based on their category data

ぃ、小莉子 提交于 2019-12-08 13:33:09
问题 I have a stores and categories model. A store can have many categories. I'm trying to create a Related Stores list for each store. I'd like to calculate a score based on the # of common categories a store shares with another. I have the plan, but not sure how to begin coding this in Ruby on Rails. Any advice? PS. I think it would be best to have a separate table to store this calculated data for each store -- since doing it realtime would be intense on the DB. UPDATE I just spotted a MAJOR

Rails 3.1: Intermittent 500 Internal Server Error when serving uncompressed assets

安稳与你 提交于 2019-12-08 12:04:26
问题 I'm upgrading an app to Rails 3.1. Quote often, Firebug will complain about some assets. Here are some errors pasted from Firebug: "NetworkError: 500 Internal Server Error - http://unstilted.dev/assets/jquery-ui.js?body=1" jquery...?body=1 "NetworkError: 500 Internal Server Error - http://unstilted.dev/assets/admin/pages/file_attachments.js" file_a...ents.js "NetworkError: 500 Internal Server Error - http://unstilted.dev/assets/admin/file_attachments/sortable.js?body=1" sortab...?body=1

How to remove infinite redirect loop after I set force_ssl to false in heroku?

雨燕双飞 提交于 2019-12-08 11:27:25
I'm working on a Rails 3.1.0 app that needs to have ssl in some pages depending on the user. I setted config.force_ssl to false in config/enviroments/staging.rb. Added a before filter that decides whether or not to redirect to http. The redirect works in development if I clean the cache. The thing is in staging, it results in a redirect loop. I believe that force_ssl uses a permanent redirect, therefore when the DNS is asked about a page in my app, it still tries to redirect to the page with ssl. Does this make any sense? What are my options? EDIT I cleaned the cache. This only solves the

How To:Debugging Rails 3.1.x app(Ruby 1.9.3) on Aptana Studio3 in Ubuntu

白昼怎懂夜的黑 提交于 2019-12-08 11:00:18
问题 Is rails debugging supported on Aptana Studio 3. I have earlier debugged Rails applications on Aptana Studio2 with the embedded browser and embedded servers. 1)How to start rails application in Debug Mode? 2)How to enable remote debugging in firefox? My work environment is as follows and I have been using RVM Rails 3.1.x Ruby 1.9.3 Ubuntu 10.10 I have already installed the debug related gems ruby-debug-base19 (0.11.25) ruby-debug-ide19 (0.4.12) 回答1: Try removing (commenting out) ruby-debug