天道酬勤,学无止境

ruby-on-rails

Capistrano deploy - assets precompile error

I am deploying with Capistrano to my new VPS. After the first deploy(cap deploy) everything was OK (site was running), but the second deploy failed on assets:precompile error. I am running rails 3.2.13, ruby 2.0.0, rvm. error: * executing "cd -- /home/rails/releases/20140116121250 && RAILS_ENV=production RAILS_GROUPS=assets bundle exec rake assets:precompile" servers: ["IP"] [IP] executing command *** [err :: IP] bash: line 1: 23406 Killed RAILS_ENV=production RAILS_GROUPS=assets bundle exec rake assets:precompile command finished in 84187ms *** [deploy:update_code] rolling back * executing

2021-06-15 18:03:27    分类:问答    ruby-on-rails   deployment   ruby-on-rails-3.2   capistrano   asset-pipeline

How do I keep paperclip from deleting attachments from an acts_as_paranoid model?

I have a model with a couple of different image attachments managed by paperclip. Recently we changed the behavior of the model so it could be soft-deleted and revived using acts_as_paranoid. Everything works great except that when we soft delete the model, paperclip is deleting the attachments as well. I've looked through the paperclip docs and the code and I don't see an obvious way to circumvent this. I'd like to be able to tell paperclip to ignore the delete callbacks on the model and keep the attachments around?

2021-06-15 18:00:44    分类:问答    ruby-on-rails   paperclip

Sort alphabetically in Rails

How do I sort an array in Rails (alphabetical order). I have tried: sort_by(&:field_name) which that gives me an array with capital letter order and then lower case order. I have tried: array.sort! { |x,y| x.field_name.downcase <=> y.field_name.downcase } Is there any way to solve this?

2021-06-15 17:59:41    分类:问答    ruby-on-rails   sorting

ExecJS::RuntimeError: SyntaxError: Unexpected token operator

RAILS_ENV=production rake assets:precompile --trace Digest::Digest is deprecated; use Digest Digest::Digest is deprecated; use Digest ** Invoke assets:precompile (first_time) ** Invoke assets:environment (first_time) ** Execute assets:environment ** Invoke environment (first_time) ** Execute environment ** Execute assets:precompile rake aborted! ExecJS::RuntimeError: SyntaxError: Unexpected token operator «=», expected punc «,» (line: 159, col: 25, pos: 5132) Error at new JS_Parse_Error (/tmp/execjs20161124-23752-1wuk17bjs:3623:11948) at js_error (/tmp/execjs20161124-23752-1wuk17bjs:3623:12167

2021-06-15 17:59:25    分类:问答    ruby-on-rails   ruby-on-rails-4   asset-pipeline

Ruby websocket client for websocket-rails gem

I am developing a rails webpage which need to use websocket functionality to communicate with an external ruby client. In order to do this, I am using the websocket-rails gem in the rails server, definning the client_connected client_disconnected event and a specific action to received the messages from the client (new_message). On the client side I have tried to use different ruby gems like faye-websocket-ruby and websocket-client-simple but I always obtain errors when I try to send a message. On the server I can't find the way to process these messages. Both gems has a send method with only

2021-06-15 17:53:30    分类:问答    ruby-on-rails   websocket   ruby-on-rails-4.1

Can Ruby Geocoder return just the street name on reverse_geocode calls?

The geocoder gem will automatically reverse geocode on save if the line after_validation :reverse_geocode is included in the model. This results in a long string of text being saved as the address, though - the format is something like "Street Name, City Name, County Name, State Name, Zip Code, Country Name". I'm only interested in the street name for this particular project, so I'm wondering if there's a way to modify the after_validation call to only save that information. If I do the reverse geocoding manually, I can access the road value in the result: place = Place.first result = Geocoder

2021-06-15 17:17:53    分类:问答    ruby-on-rails   rails-geocoder

How do you do a rolling deploy with capistrano?

We have 2 instances behind a load balancer running the same rails app with passenger. When we deploy, the server startup time causes requests to timeout. As a result we have a script that updates each webserver individually by taking one off the LB, deploying with cap, testing a dynamic page load, putting it back on the LB. How can we get capistrano to do this for us with one command? I have been able to set it up to deploy to all instances simultaneously but they all restart at the same time and cause the site to be unavailable for 20 seconds. What am I missing here? Seems like this should be

2021-06-15 17:06:57    分类:问答    ruby-on-rails   deployment   amazon-ec2   capistrano   load-balancing

how can i insert a variable in to a href value in a link in rails?

i have: <a href="/patients/#{@appointment.patient.id}"> <%=h @appointment.patient.f_name %> <%=h @appointment.patient.l_name%> </a> but it dose not work due to a syntax error, if i click on the href it goes to http://0.0.0.0:3000/patients/#{@appointment.patient.id} thanks

2021-06-15 17:06:53    分类:问答    ruby-on-rails   erb

Facebook OAuth is not returning email in user info

I'm doing a spree 3.0 installation (ROR) and trying to use facebook oauth for authentication, but the fields sent back after a successful oauth, do NOT contain the email, which is critical to our application. here is the return from the facebook successful authentication. #<OmniAuth::AuthHash credentials=#<OmniAuth::AuthHash expires=true expires_at=1442435073 token="CAAJa3dyBtY4BAJ2ZB3vrenNOFJKSMtvxYO09ZCJtEsmKNBs90q9nmUF4LIBr06xCizEAR3lwht3BwycLkVFdjlvkS1AUGpYODQHu25K0uO8XLDDPkTO0E9oPdIILsbTTOuIT7qcl8nJ6501z0dCXEi9hVNwPYqZBbGqiEhyoLyVgCNnDWdPRLBRF5xSovJdhjjCf6XC8ulJ4NnKBfM8"> extra=#<OmniAuth

2021-06-15 17:05:48    分类:问答    ruby-on-rails   spree   facebook-oauth

Should rails models be concerned with other models for the sake of skinny controllers?

I read everywhere that business logic belongs in the models and not in controller but where is the limit? I am toying with a personnal accounting application. Account Entry Operation When creating an operation it is only valid if the corresponding entries are created and linked to accounts so that the operation is balanced for exemple buy a 6-pack : o=Operation.new({:description=>"b33r", :user=>current_user, :date=>"2008/09/15"}) o.entries.build({:account_id=>1, :amount=>15}) o.valid? #=>false o.entries.build({:account_id=>2, :amount=>-15}) o.valid? #=>true Now the form shown to the user in

2021-06-15 16:42:56    分类:问答    ruby-on-rails   ruby