ruby-on-rails-3.1

remote select, controller needs more form data

扶醉桌前 提交于 2019-12-06 16:15:30
问题 I have two select fields in a form. Every time one of these select fields change value, the rest of the form should be changed. I used the following code for the select fields: <%= f.collection_select :model1, Model1.all, :id, :name, "data-remote" => true, "data-url" => "/model3/get_rest_form" %> <%= f.collection_select :model2, Model2.all, :id, :name, "data-remote" => true, "data-url" => "/model3/get_rest_form" %> The problem now is that the model3 controller needs the values of both select

Rake and Uninitialized Constants

青春壹個敷衍的年華 提交于 2019-12-06 15:39:33
I have spent hours upon days trying to resolve this. Rake is throwing the following error: dcarpenter$ rake rake aborted! uninitialized constant ActionView::Helpers::JavaScriptProxy I can't seem to find anyone who has had this issue on Google, this site or elsewhere. What steps should I take to resolve this and what do I need to know? rake --trace yields: /Users/dcarpenter/Dropbox/workspace/gems/rake-0.9.2/lib/rake/ext/module.rb:36:in `const_missing' /Users/dcarpenter/Dropbox/workspace/gems/jrails-0.6.0/lib/jrails.rb:231:in `<module:Helpers>' /Users/dcarpenter/Dropbox/workspace/gems/jrails-0.6

Putting Javascript at the end of the file using Rails 3.1 asset pipeline

旧时模样 提交于 2019-12-06 15:39:14
Sometimes in heavy client side Javascript we put the tags at the end of the HTML file so that the content is displayed first while Javascript is loaded afterwards. Is it possible to do this using Rails 3.1 assets pipeline? EDIT: <html> <head> <%= javascript_include_tag "application" %> </head> <body> <!-- all the page content goes here --> <!-- we include these at the bottom to ensure the html loads first and the javascript is loaded afterwards. How can we achieve this through rails asset pipelining? --> <script src="/some_other_assets/first_file.js"></script> <script src="/some_other_assets

Sending data in my form hidden field

白昼怎懂夜的黑 提交于 2019-12-06 15:38:47
I am trying to add a jquery upload But i need to pass a parameter into my form Here the form <%= form_for Photo.new do |f|%> <%= f.label :title %><br /> <%= f.text_area :title, :rows => 3, :value => "Add a photo", :onclick=>"this.value='';" %> <%= f.file_field :photo, multiple: true %> <%= f.hidden_field('event_id', params[:event_id]) %> <%= f.submit "Add Picture" %> <% end %> But this doesn't work, the issue is I have a link has follow localhost/events/16/photos/useradd where 16 is the event_id params. How can i place it into my hidden field so it is send afterwards? UPDATE NoMethodError in

Error Messages Showing in Production - Ruby on Rails 3.1, Nginx, Unicorn

岁酱吖の 提交于 2019-12-06 14:55:31
I have a Rails 3.1 app running in production using Nginx and Unicorn. And for some reason, my custom 404 and 500 html error pages are not showing. Instead I'm getting the actual error message ("Routing Error", for example). In my production.rb file, I have config.consider_all_requests_local = false And on the same server with a nearly identical configuration, I have a 'staging' site that works just fine. The only difference, as far as I can tell, is that the production one has SSL while the staging does not. Here is the Nginx config for the production app: upstream unicorn_myapp_prod { server

run rake task inside rails application

梦想的初衷 提交于 2019-12-06 13:53:42
I want to run asset precompile task inside the rails application,As I had many dependencies who will change the code,in that case all the time whenever they change i need to run the script as I cant give server access to them so I am providing the GUI for them from that they alone can run the script,so,I have built UI to run the task with some parameter like system("Template='#{params[:template]}' Theme='#{params[:theme]}' rake assets:precompile) I am getting two values from UI(params[:template],params[:theme]).Another thing i want to run this task in another path(site path) means Admin side

Facing error installing mysql2 gem

坚强是说给别人听的谎言 提交于 2019-12-06 13:35:29
Rails ask me to succeed with gem install mysql2 and on trying I got the following error.So what is mostly problem with such error? Detail of error is below: Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options. Provided configuration options: --with-opt-dir --without-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib --without-opt-lib=${opt-dir}/lib --with-make-prog --without-make-prog --srcdir=. --curdir --ruby=/usr/local/bin/ruby --with

Passenger + Rails 3.1.1 = Could not find rake-0.9.2 in any of the sources (Bundler::GemNotFound)

只谈情不闲聊 提交于 2019-12-06 13:14:32
问题 I know there are already some threads about this error, but none of them solved my problem. I started a new rails app with rails 3.1.1 and RVM Ruby 1.9.2-p180. It works when I use rails server and go to localhost:3000 But when I try to host it like my other Rails 3.0.x apps using Passenger (OSX pref pane) and visit it in the browser I get the following error: Error message: Could not find rake-0.9.2 in any of the sources (Bundler::GemNotFound) Exception class: PhusionPassenger::UnknownError

Sending mails automatically through action mailer Rails 3.1

纵饮孤独 提交于 2019-12-06 13:06:09
问题 I have to send weekly emails to all the user about the latest things happening. I am using ActionMailer to accomplish other mailing task however I have no clue how to automate the weekly emails. Update I found whenever gem which could be used to schedule cron jobs. I guess this could be used to send weekly emails which I intend to. Still looking how to make it work with ActionMailer will update once I find the solution Update 2 This is what I have done so far using whenever gem:- in schedule

rails 3.1, devise gem, :timeoutable is not working, why?

拥有回忆 提交于 2019-12-06 12:44:32
I am trying to use the auto signout feature, here is my model: class Student < ActiveRecord::Base devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :timeoutable def timeout 3.seconds end end here is the routes.rb: devise_for :students do get '/students/sign_out' => 'students/sessions#destroy' end I sign-in, then I wait 5 seconds, at this time, student session should be expired, but, if vavigating to any other protected page is not redirecting back to login form, meaning that the session is still active. Is there something I am missing ??