Rails

Rails: Moving `master.key` to production server

匿名 (未验证) 提交于 2019-12-03 01:45:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to deploy an updated version of a rails app to a droplet on DigitalOcean using mina When I run mina deploy I get the error Missing encryption key to decrypt file with. Ask your team for your master key and write it to /home/my_rails_project/app/tmp/build-153920174210305/config/master.key or put it in the ENV['RAILS_MASTER_KEY'] . I was expecting this error as I haven't yet worked out how to add the details to the server. A number of articles suggest there are two means of doing this : Option 1: Place the config/master.key file in

Rails to redirect View link to page user wanted to view prior to login

匿名 (未验证) 提交于 2019-12-03 01:44:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I am new to rails I have an HTML.erb like this <h1> books List </h1> <table id = "book" border = "3" layout = "fixed" width = " 100%" > <tr> <th> Name </th> <th></th> <th></th> <th></th> </tr> <% @books . each do | book | %> <tr > <td> <%= book . name %> </td> <td> <%= link_to 'VIEW' , book %> </td> </tr> <% end %> </table> Here I wanted to redirect to the actual books page the user wanted to view after user login where the login popup will come when user clicks the view button if user is not logged in. So how can I do it. For my

Capybara: undefined method &#039;visit&#039;

匿名 (未验证) 提交于 2019-12-03 01:43:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: When running my specs with rspec & capybara, it can't find capybara's visit method. Is there another initialization step I need to do? $bundle exec rspec spec /home/brian/projects/expense_track/expense_track/spec/requests/homepage_spec.rb:6:in `block (2 levels) in ': undefined method `visit' for #0xb6572b8> & ''

Rails: ActiveModel::ForbiddenAttributesError

匿名 (未验证) 提交于 2019-12-03 01:42:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to use OmniAuth to integrate Facebook with my website, and I think I'm getting a few errors here. Right now when I click "Sign in with Facebook" it does bring me to Facebook, but soon as I sign in I get an error saying ActiveModel::ForbiddenAttributesError . Also, I think there might be an issue my routes as well but I'm not sure. Also, I followed this RailsCasts tutorial: http://railscasts.com/episodes/360-facebook-authentication?autoplay=true Edit: The error is on this line here, where(auth.slice(:provider, :uid)).first_or

Ruby on Rails: How to run things in the background?

匿名 (未验证) 提交于 2019-12-03 01:41:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: When a new resource is created and it needs to do some lengthy processing before the resource is ready, how do I send that processing away into the background where it won't hold up the current request or other traffic to my web-app? in my model: class User 回答1: You should definitely check out the following Railscasts: http://railscasts.com/episodes/127-rake-in-background http://railscasts.com/episodes/128-starling-and-workling http://railscasts.com/episodes/129-custom-daemon http://railscasts.com/episodes/366-sidekiq They explain how to run

Getting error in logs ActiveSupport::MessageEncryptor::InvalidMessage when try to deploy Rails 5.2.0 App

匿名 (未验证) 提交于 2019-12-03 01:41:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to deploy a Rails 5.2.0 App on ec2 instance using mina deploy and When it tries to Migrate database it is aborted with following error logs. -----> Migrating database WARNING: Use strings for Figaro configuration. 2 was converted to "2". WARNING: Use strings for Figaro configuration. 5 was converted to "5". I, [2018-07-07T15:15:56.316810 #15933] INFO -- sentry: ** [Raven] Raven 2.7.4 ready to catch errors I, [2018-07-07T15:15:56.579121 #15933] INFO -- sentry: ** [Raven] Raven 2.7.4 ready to catch errors [Simple Form] Simple Form

rake assets:precompile stuck

匿名 (未验证) 提交于 2019-12-03 01:40:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: couple of days ago i noticed that jquery calendar is not working on my deployment site(heroku). on digging out the problem i noticed that source of site on my dev server has some 100 script tags related to bootstrap(i am using twitter bootstrap css) but on prod server. i have 4 script tags. on searching i found that i should run rake assets:precompile on my rails console fo asset pipeline. but while running it is taking terribly long time, last time it took 6 hours and i had to abort it. referring to many sites and post, i found that i

Rails 3 - retrieving last accessed action/controller from current controller

匿名 (未验证) 提交于 2019-12-03 01:40:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I need to be able to set my nav on the current page depending on which page the user was perviously on. e.g pageX => pageA(tab1selected) pageY => pageA(tab2selected) I know from reading you can use request.env["HTTP_REFERER"] but I read this doesnt always get return if the user has a firewall etc I am using devise in my app if that helps. Is there another method ? Thanks Alex 回答1: Though not a quick solution, it works: At the end each controller with view , call a method to set your store your current action in the session. If you

rails postgres ERROR: invalid input syntax for type double precision

匿名 (未验证) 提交于 2019-12-03 01:39:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: i'm trying the following: user_calendars.where("extract(day from time_from) = ? ", next_day) But i keep getting this Error: PG::InvalidTextRepresentation: ERROR: invalid input syntax for type double precision: "Saturday" LINE 1: ..."user_id" = $1 AND (extract(day from time_from) = 'Saturday'... Not sure why it points out type double. 回答1: In PostgreSQL, the expression extract(day from time_from) returns a number of type double, representing the day of the month. Saturday is clearly not a valid double. If you need the argument to where() to

Rails Sti: single path, different controller

匿名 (未验证) 提交于 2019-12-03 01:39:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Have STI classes: class Page < ActiveRecord::Base belongs_to :user end class FirstTypePage < Page end class SecondTypePage < Page end Controllers for each class, class PageController < AplicationCorroller end class FirstTypePageController < PageController end class SecondTypePageController < PageController end And routings: resources :user resource :page end How to handle FirstTypePage by FirstTypePageController, SecondTypePage by SecondTypePageController on single path? i.e. user/1/page/2 is handled by: FirstTypePageController if "page 2"