ruby-on-rails-3.2

Rails precompile assets - Cannot access precompiled files locally

僤鯓⒐⒋嵵緔 提交于 2019-12-08 09:15:18
问题 I have a mysterious problem in my rails application, which I cannot fix. The thing is that I want to precompile my CSS and JavaScripts and run the server on the staging environment locally to check if everything is ok, before I deploy to the server. I run this command to precompile the files: rake assets:precompile RAILS_ENV=staging To start the server in staging environment i run this command: rails s -e staging The files are being precompiled successfully and placed in the public/assets

Rails 3.2 - collection_select Adding A Null Entry In The First Position Of My Array

馋奶兔 提交于 2019-12-08 08:23:14
问题 I have a Ruby on Rails 3.2.13 application where I have a collection_select statement. The collection_select statement is in a fields_for statement where I gather selected ids from the collection_select and use them to populate another table. The problem I am having is that the collection_select statement adds a null id entry in the array that stores the collection of selected ids. Here is my code in my view: <%= f.fields_for :media_topics do |media_topic| %> <%= media_topic.label :topic,

After removing caches_page cached sites are still not updated

谁都会走 提交于 2019-12-08 07:43:05
问题 I played a bit with caching. I added caches_page :show to my ArticlesController and it causes me terrible pain. I removed the caches_page from the controller but nothing happened. I restarted the server (thin + nginx) but nothing happened. I cleaned the cache via console Rails.cache.clear in production mode and restarted the server again. Now it's working again for the articles I didn't call but the one that were cached are still not refreshed. I already cleaned the cache of my browser but it

How do i solve FbGraph::Unauthorized: OAuthException :: (#200) The user hasn't authorized the application to perform this action

依然范特西╮ 提交于 2019-12-08 07:39:15
问题 I am getting error FbGraph::Unauthorized: OAuthException :: (#200) The user hasn't authorized the application to perform this action.My omniauth.rb look like this: Rails.application.config.middleware.use OmniAuth::Builder do provider :facebook, ENV['FACEBOOK_APP_ID'], ENV['FACEBOOK_SECRET'], {:scope => "offline_access, publish_stream, user_photos, publish_checkins, photo_upload"} end and my controller contains: me = FbGraph::User.me(ACCESS_TOKEN) me.feed!( :message => 'Updating via FbGraph',

find_in_batches does not use given order but uses id asc

青春壹個敷衍的年華 提交于 2019-12-08 07:14:30
问题 How can I use ordering as it is? Any help will be appreciated. Thank u! see the code- selected_catalog_products.find_in_batches(batch_size: 4) do |cps| # my code end 回答1: It’s not possible to set the order. The order is automatically set to ascending on the primary key (“id ASC”) to make the batch ordering work. http://apidock.com/rails/ActiveRecord/Batches/find_in_batches 来源: https://stackoverflow.com/questions/32005165/find-in-batches-does-not-use-given-order-but-uses-id-asc

Create a custom Rails Logger

馋奶兔 提交于 2019-12-08 05:44:26
Is this outdated? http://guides.rubyonrails.org/debugging_rails_applications.html I am following it step by step, And in part '2.1 What is the Logger?' It says how to create a custom logger. 1) You can specify an alternative logger in your environment.rb or any environment file: Rails.logger = Logger.new(STDOUT) Rails.logger = Log4r::Logger.new("Application Log") I put this code in my environment.rb file and I get this: uninitialized constant Log4r (NameError) ..then it says 'Or in the Initializer section, add any of the following:' config.logger = Logger.new(STDOUT) config.logger = Log4r:

UserMailer with Devise

假装没事ソ 提交于 2019-12-08 05:31:25
am using my custom mailer UserMailer to send emails. It works perfect in development, but in production i get error 500, that is when am trying to retrieve my password on forgetting. here is what is in the production logs in the production mode Processing by Devise::PasswordsController#create as HTML Parameters: {"utf8"=>"✓","authenticity_token"=>"xxxxxxxxxxxxxxx", "user"=>{"email"=>"sam@gmail.com"}, "commit"=>"Send me r$ Completed 500 Internal Server Error in 2ms NameError (uninitialized constant Devise::UserMailer): activesupport (3.2.8) lib/active_support/inflector/methods.rb:230:in `block

Unexpected memcache GETs in rails 3.2 app

不羁岁月 提交于 2019-12-08 04:25:46
问题 My rails 3.2 app is trying to fetch values from the cache (memcached via dalli) that I'm not expecting it to be caching. It's not getting any cache hits, but I'm puzzled about what is going on. This happens with config.action_controller.perform_caching = true on production as well as development, using WEBrick. Here's a snippet of what I'm seeing in memcache verbose output: <30 GET https://www.myrailsapp.com/? >30 Writing an error: Not found >30 Writing bin response: >30 0x81 0x00 0x00 0x00

Rails Gem with model-relationships for Rails Engines

ぐ巨炮叔叔 提交于 2019-12-08 04:23:35
问题 I'm just developing a Rails application which will have many Engines. However, I'm not able to edit relationships inside the Engines. To solve this issue, I want to create a relationships-Gem which will be included in the Application and defines the relationships (see: https://stackoverflow.com/a/11835899/603126). Let's assume, I have a User (namespaced and isolated) Engine and a Comment (namespaced and isolated) Engine. What I want is to override / extend the relationships inside the

Active Admin NoMethodError Error

*爱你&永不变心* 提交于 2019-12-08 02:50:19
问题 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