ruby-on-rails-3

Rails 4/ ajax - NoMethodError - undefined method `id' for nil:NilClass - Passing variable to js modal

﹥>﹥吖頭↗ 提交于 2020-01-06 11:46:55
问题 I have a pretty simple Ruby On Rails app with bootstrap 3 for the front end: I have Deals, and each Deal has_many Opportunities. On each Deal page (url of deal page is for example myapp.com/id=1), I want to have a textual link that says "view deal's opportunities" and when clicked, it trigger when clicked the appearance of content inside a Bootstrap modal. I'm getting all mixed up because on this Deal Page, I use Deal's controller action called "showcase". BUT to generate the modal via ajax

ROR + Ruby Date in Different Format

匆匆过客 提交于 2020-01-06 10:09:13
问题 If I have @today = Thu Apr 21 2011 00:00:00 GMT 0530 (IST), How do I convert @today into "Thur April 21, 2011" ? 回答1: Time.now.strftime("%a %B %d, %Y") => "Fri April 15, 2011" In your occasion : @today.to_time.strftime("%a %B %d, %Y") => "Thu April 21, 2011" 来源: https://stackoverflow.com/questions/5674260/ror-ruby-date-in-different-format

How to pass extra params inside option hash in confirmation email in Rails?

寵の児 提交于 2020-01-06 09:57:24
问题 I am trying to pass extra params inside the options{} hash in the confirmation email but It is just showing me subject and from headers in the mailer. This is my code CustomMailer.confirmation_instructions(user,token, {custom_param: "abc"}) When I show opts data inside template like this @first_name = opts It shows {:subject=>"Email Confirmation", :from=>"no-reply@sample.com"} custom mailer code is class CustomMailer < Devise::Mailer helper :application # gives access to all helpers defined

How to pass extra params inside option hash in confirmation email in Rails?

霸气de小男生 提交于 2020-01-06 09:55:29
问题 I am trying to pass extra params inside the options{} hash in the confirmation email but It is just showing me subject and from headers in the mailer. This is my code CustomMailer.confirmation_instructions(user,token, {custom_param: "abc"}) When I show opts data inside template like this @first_name = opts It shows {:subject=>"Email Confirmation", :from=>"no-reply@sample.com"} custom mailer code is class CustomMailer < Devise::Mailer helper :application # gives access to all helpers defined

Rails 3.1 ckeditor: Adding fontsize in toolbar?

筅森魡賤 提交于 2020-01-06 09:32:47
问题 I have ckeditor in my rails 3.1 app but I am not able to add fontsize and font dropdowns to my toolbar. My edit view code: <%= javascript_include_tag "ckeditor/ckeditor.js" %> ... <%= form_for @page, :html => { :class => 'edit_page', :id => "page_form" } do |page| %> ... <%= page.cktext_area :content, {:height => "350px", :width => "920px"}%> ... <% end %> I am able to adjust the height and width but not add any other parameters? 回答1: Could be late but in rails 3.1 app you can go to /vendor

Rails 3.1 ckeditor: Adding fontsize in toolbar?

廉价感情. 提交于 2020-01-06 09:31:14
问题 I have ckeditor in my rails 3.1 app but I am not able to add fontsize and font dropdowns to my toolbar. My edit view code: <%= javascript_include_tag "ckeditor/ckeditor.js" %> ... <%= form_for @page, :html => { :class => 'edit_page', :id => "page_form" } do |page| %> ... <%= page.cktext_area :content, {:height => "350px", :width => "920px"}%> ... <% end %> I am able to adjust the height and width but not add any other parameters? 回答1: Could be late but in rails 3.1 app you can go to /vendor

form :remote => true, submitted twice in IE

六月ゝ 毕业季﹏ 提交于 2020-01-06 08:58:10
问题 I have a form tag with like following: <%= form_tag(new_invitations_invitations_path, :remote => true) do %> <%= hidden_field_tag(:provider, "yahoo") %> <dl> <dt><strong>Your email:</strong></dt> <dd><%= text_field_tag('email') %></dd> </dl> <dl> <dt><strong>Password:</strong></dt> <dd><%= password_field_tag('pass') %></dd> </dl> <dl> <dt> </dt> <dd><%= submit_tag "Import your address book", :disable_with => "Please wait..." %></dd> </dl> <% end %> Above gives output HTML as following: <form

Rails: Associate posts with user and location

这一生的挚爱 提交于 2020-01-06 08:56:13
问题 I have a Post model in my app, which belongs_to a User model, as well as a Location model. Both the User and Location models use the has_many relation with Post . Now, in my Post controller's create action, I want to automatically associate the Post with the currently logged in user (available to me as current_user through Devise). Also, it should associate with a pre-existing Location if one exists with the same address field (which he enters through the form), or create a new one and

Can not install rails 3.0 for Massive Record

妖精的绣舞 提交于 2020-01-06 08:45:13
问题 I am Trying to install rails 3.0 to use with Massive Record Gem. But when I am trying to install, the gem rails -v 3.0.0 is installed successfully. But, When I do rails -v it shows error : /home/mayukh/.rvm/gems/ruby-2.1.2@global/gems/rubygems-bundler-1.4.4/lib/rubygems-bundler/noexec.rb:84:in setup': undefined method rubygems' for Bundler:Module (NoMethodError) Please find the Ruby, Bundler details and error details below: 回答1: That's a really old bundler version that is compatible with

Nested model form not working properly - need to pinpoint POST/GET redirect

此生再无相见时 提交于 2020-01-06 08:37:05
问题 I have a nested model form that isn't functioning properly. The POST is to the proper place, but then the GET reroutes me. So I'm wondering if anyone can help explain what I'm doing wrong. I have two models: User and Profile . Code for them below: User: class User < ActiveRecord::Base attr_accessor :password, :email has_one :profile, :dependent => :destroy accepts_nested_attributes_for :profile ... end Profile: class Profile < ActiveRecord::Base attr_accessible :first_name, :last_name, etc.