ruby-on-rails-3.2

Active Admin NoMethodError Error

大城市里の小女人 提交于 2019-12-06 09:47:18
Im setting up active admin on my rails app. I ran the generator to create the user resource but when i click on the users link on the admin dashboard i get: NoMethodError in Admin/users#index Showing /Users/nelsonkeating/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/activeadmin-0.4.4/app/views/active_admin/resource/index.html.arb where line #1 raised: undefined method `city_id_contains' for #<MetaSearch::Searches::User:0x007fde92d69840> Extracted source (around line #1): 1: render renderer_for(:index) I have no clue what is generating this or where the error is coming from.. Any ideas?

Active Model MassAssignmentSecurity Error

耗尽温柔 提交于 2019-12-06 09:09:26
问题 I'm Getting an Error: I'm developing a web with Facebook Integration.. I'm new in ruby on rails. can you help with my problem. ActiveModel::MassAssignmentSecurity::Error in SessionsController#create Can't mass-assign protected attributes: name This is my controller: class SessionsController < ApplicationController def create #render :json => request.env['omniauth.auth'].to_yaml auth = request.env['omniauth.auth'] unless @auth = Authorization.find_from_hash(auth) @auth = Authorization.create

Devise + Omniauth call action passthru on login Facebook

你离开我真会死。 提交于 2019-12-06 08:14:21
问题 When I try to login with Facebook using Omniauth and Devise, passthru is called instead of facebook . How do I pass in the link_to : user_omniauth_authorize_path(:facebook) I've revised the code many times and tried to use this route: devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" } do get '/users/auth/:provider' => 'users/omniauth_callbacks#passthru' end and devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" } But

Huge json object to excel?

白昼怎懂夜的黑 提交于 2019-12-06 08:05:21
I have a PHP application which has a table with more then 10000 rows and I am trying to export that into an excel sheet via my ROR application but my request is getting timed out on the server by PHP application.So I was wondering is there any elegant way to solve this problem. I come up with 2 solutions. First is doing a batch processing (need to read about as I am new with it) and the other is that my php application will send a large json object and my ruby app will read that json object write the data to excel sheet and sends back the excel sheet.So I wanted to ask whether is there any

Resize missing.png depending upon style in paperclip

一世执手 提交于 2019-12-06 07:20:13
问题 I'm using Paperclip to upload a image here my paperclip configuration has_attached_file :avatar, :path => ":rails_root/public/users/:id/avatar/:style/avatar.jpg", :url => "/users/:id/avatar/:style/avatar.jpg", :default_url => "/missing/users/:style/missing.png", :styles => {"47x47" => "47x47", "228x228" => "228x228","185x176"=>"185x176","pitch_planner"=>"262x129!"}, :convert_options => {"47x47" => "-background black -gravity center -extent 47x47", "228x228" => "-background black -gravity

Can 'rails g controller' generate restful routes?

杀马特。学长 韩版系。学妹 提交于 2019-12-06 07:18:34
问题 Is there a way, using rails generators, to create a controller with RESTful routes? Generating a controller and specifying the action name creates a controller and adds a route to config/routes.rb , but create is a get : $ rails g controller foos new create create app/controllers/foos_controller.rb route get "foos/create" ... I'd prefer to see route post "foos" , but don't see anything useful in rails g controller --help 回答1: Try using rails generate scaffold_controller Foos 来源: https:/

How to protect my e-mail address from spambots

梦想的初衷 提交于 2019-12-06 06:57:40
I was wondering what rails offers to obfuscate e-mail addresses to protect it from crawlers, spambots and mail harvesters, gathering addresses to send spam. May be I used wrong keywords, but wasn’t really able to find a gem. I found a statistic comparing different methods to mask the mail address: http://techblog.tilllate.com/2008/07/20/ten-methods-to-obfuscate-e-mail-addresses-compared/ I wrote a snippet that combines the top two methods. The snipped isn’t mature yet, but I like to share it anyway, it might be a starting point for others facing the same issue. (One next step would be to

Passing a local variable to a partial that is rendered after the view has already loaded

限于喜欢 提交于 2019-12-06 06:39:37
问题 Update: I just found this other thread that explains why I am having this issue ( Pass local rails variable to javascript to partial ), but it did not list out the steps to fix it (or at least it skipped too many steps that I don't yet know how to do.) The issue seems to be that the local variable being passed to the partial is no longer the same local variable that existed when new.html.erb was loaded since the partial is not loaded until the click event. Is it possible to get around that?

How to upgrade Rails app from 2.3.5 to 3.2.x?

…衆ロ難τιáo~ 提交于 2019-12-06 05:43:45
问题 I have Rails 2.3.5 app, I want to upgrade to 3.2.x. How do I upgrade to Rails 3.2.x? Thanks 回答1: I definitely recommend installing the Rails upgrade gem (rails upgrade gem). It's proven for me to be incredibly useful as a starting point for listing and verifying all the required upgrades to get to Rails 3.0. I would also recommend this ebook http://www.railsupgradehandbook.com/ Once you're at Rails 3.0, you'll need to migrate to the asset pipeline, this is another good starting point: http:/

Helpers use a lot of memory in rails 3(.2)

こ雲淡風輕ζ 提交于 2019-12-06 05:06:59
问题 While migrating a rails 2 app to rails 3 I encountered a huge increase in memory used. After some research I found out the helpers were the problem. Uncommenting any helpers in the view would speed everything up. Things I tried to find the real issue: include_all_helpers = false disable parts of the helper files clean up the code by refactoring Model.all usages to some faster code I got a theory now that some helpers might be renamed or deleted, rails starts to search for them and starts