ruby-on-rails-3

Bootstrap modal form is committing twice

╄→гoц情女王★ 提交于 2020-01-07 04:34:07
问题 I have a modal form: <div id="commentModal" class="modal hide fade"> <div class="modal-body"> <%= form_for(Comment.new, remote: true, html: {"data-type" => :json}, :validate => true) do |f| %> <%= f.hidden_field(:illustration_id, :value => @illustration.id) %> <%= f.hidden_field(:user_id, :value => current_user.id) %> <%= f.text_area(:comment, :id => "comment_message") %> <%= f.submit "Submit", :class => 'btn btn-custom-primary' %> <% end %> </div> </div> When I submit the comment is added to

Pass data in form of variable -Highcharts

*爱你&永不变心* 提交于 2020-01-07 04:29:06
问题 I am trying to implement high charts(pai chart) in my system where I am trying to pass the the value of data from a variable which contains the value in exact array manner that data required, alert(legend_with_values) If I am alerting this variable it returns [['agent_total_members',24],['billing_failed',0],['members_inactive',0],['members_expired',0] ] I am Passing this value to the data field like this legend_with_values; alert(legend_with_values); this alert returns [['agent_total_members'

jQuery masonry plugin not being activated

拈花ヽ惹草 提交于 2020-01-07 03:12:10
问题 I'm trying to implement the jquery masonry images plugin, it seems to be setup right, but it's not working! I debugged using my browser, and didn't see any errors. What could I be doing wrong? Code is below. Thanks. Faisal <script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script> <script src="/assets/jquery.js"></script> <script src="/assets/jquery.masonry.min.js"></script> <style> .item { width: 200px; .... } </style> <div id="container"> <div class="item"> .... <

Public_Activity returning an object instead of result

半世苍凉 提交于 2020-01-07 02:58:06
问题 I installed the public_activity gem following the railscasts tutorial. The activities page in the browser is returning an object instead of the actual event that the activity is referring to. class ActivitiesController < ApplicationController def index @activities = PublicActivity::Activity.order("created_at desc") end end Migration responsible for creating a table with activities: class CreateActivities < ActiveRecord::Migration # Create table def self.up create_table :activities do |t| t

:entry_name does not change for will_paginate; not working?

◇◆丶佛笑我妖孽 提交于 2020-01-07 02:16:11
问题 Does anyone know why the entry name isn't changing to what I want? <div class="digg_pagination"> <div class="page_info"> <%= page_entries_info @user_prices, :entry_name => 'Price', :plural_name => 'Prices' %> </div> <%= will_paginate @user_prices, :container => false %> </div> I already tried getting rid of the :plural_name option but that didn't work either. What could be the problem? 回答1: At some point the :entry_name option in page_entries_info has changed to :model . So you can now do (in

switching from Sqlite3 to PostgreSQL on an existing rails application

淺唱寂寞╮ 提交于 2020-01-07 02:01:50
问题 When I tried to switching from sqlite3 to postgresql in my existing application I faced this problem with rake db:migrate , I did the following 1 - rake db:create 2- rake db:migrate I got this error: == AddColumn1: migrating ===================================================== -- add_column(:users, :first_name, :string) rake aborted! An error has occurred, this and all later migrations canceled: PG::Error: ERROR: relation "users" does not exist 3- rake db:reset 4- rake db:migrate , now

ActionView::Template:Error(undefined method 'first_name' for nil:NilClass)

白昼怎懂夜的黑 提交于 2020-01-07 00:36:42
问题 My app seems to randomly be throwing an error when users are trying to load grid data into the form: ActionView::Template::Error (undefined method `first_name' for nil:NilClass): 3: t = @conts 4: xml.tag!("row",{ "id" => t.id }) do 5: 6: xml.tag!("cell", t.first_name) 7: xml.tag!("cell", t.last_name) 8: xml.tag!("cell", t.email) 9: xml.tag!("cell", t.phone_1) And following is the controller file def compdata @conts = Continfo.find_by_id(params[:id]) end Correspondence compdata RXML file xml

Avoiding HTML-in-string / html() in a jQuery script

萝らか妹 提交于 2020-01-06 20:17:19
问题 I want to make a jQuery based custom popup window for my site using javascript. I prototyped it by storing the HTML to go in the popup inside a javascript string variable and then display that string thus: $('#pop_div').html(string); where string is defined thus: var string= '<div class="className">' + 'HTML Content'+ '</div>' I've seen a few websites that do this but think it is incorrect. It works for static html snippets but not for rails generated html using <%= .. %> What is the best way

set secret keys for amazon aws3

。_饼干妹妹 提交于 2020-01-06 20:14:11
问题 I use fog and carrierwave. Right now I just have simple uploader that I run locally: CarrierWave.configure do |config| config.fog_credentials = { :provider => 'AWS', :aws_access_key_id => ENV['S3_ACCESS_KEY'], :aws_secret_access_key => ENV['S3_SECRET_KEY'], :region => 'us-west-1', # Change this for } config.fog_directory = "bucket-main" end But now I have a question where should I save my secret keys. On heroku environment I could print like this $ heroku config:set S3_ACCESS_KEY

Rails 3.1, internalization of values from a habtm relationship?

有些话、适合烂在心里 提交于 2020-01-06 20:06:46
问题 I got a Event model that HABTM Categories. The relationship works fine and I can insert/retrieve values from Categories with no problem. My questions is, is there a way to interzationalize(I18n) the values of this categories. Category Model class Category < ActiveRecord::Base has_and_belongs_to_many :events end Event Model class Event < ActiveRecord::Base .... has_and_belongs_to_many :categories .... _form.html.haml (for events) - Category.all.each do |category| .field = check_box_tag