ruby-on-rails-3

How SimpleForm maxlength extension works

≯℡__Kan透↙ 提交于 2020-01-03 18:11:12
问题 I want to set the maxlength html attribute of the inputs on my forms created with the help of the SimpleForm gem. I know I can do this by passing in the maxlength attribute manually when creating the form, e.g.: <%= f.input :username, input_html: { maxlength: 20 } %> But that isn’t want I want because according the comments in the SimpleForm config file you should enable the maxlength extension which adds automatically this html attribute to the input tag for string attributes when a max

Rails form_for submit button not working

爷,独闯天下 提交于 2020-01-03 18:06:32
问题 Thank you for your patience. Still pretty new to Rails. Using Rails 3.2 Making a signup page for a simple app. My problem is that the submit button on my form doesn't cause any effect, whether the information in the form is valid or not. The User model and database both seem to work fine. If I add a user manually from the rails console, it will add it to the database. As far as I can tell, the issue seems to be in the form generated by form_for. Here is the page in question: <% provide(:title

Rails form_for submit button not working

試著忘記壹切 提交于 2020-01-03 18:03:36
问题 Thank you for your patience. Still pretty new to Rails. Using Rails 3.2 Making a signup page for a simple app. My problem is that the submit button on my form doesn't cause any effect, whether the information in the form is valid or not. The User model and database both seem to work fine. If I add a user manually from the rails console, it will add it to the database. As far as I can tell, the issue seems to be in the form generated by form_for. Here is the page in question: <% provide(:title

NoMethodError: Undefined method 'type' for nil:NilClass in Rails

南楼画角 提交于 2020-01-03 17:27:30
问题 Getting a NoMethodError when trying to load up one of the pages on my website built with Rails. See the full stack trace below. If I change false to true in production.rb at line config.cache_classes = false then the problem goes away, but I have to restart the Rails server every time I make a change to any file. It seems like the problem is related to checking the type of a column in my DB, but I can't figure out how to resolve it. Controller action: def manage @view_data = {} if (@view_data

Rails 3.2 and Sass not rendering Application.css

谁都会走 提交于 2020-01-03 17:26:19
问题 I just did a major upgrade to Rails 3.2 and the newest Sass and Coffee Rails Gems, but my Application file won't render as Application.css.scss. I had it in my html as such: <%= stylesheet_link_tag 'application.css.scss' %> And when I look at the Page Source in my Development mode I'm getting <link href="/assets/application.css.scss.css" media="screen" rel="stylesheet" type="text/css" /> What the heck is going on!? It seems to append .css to everything I put inside the stylesheet_link_tag, so

how to change the position of a new column in rails 3.x migration

匆匆过客 提交于 2020-01-03 17:25:35
问题 I created a migration that simply adds a new column, but I want it to be added before the created_at and updated_at columns, is there a way to specify in which position the new column is created ? I searched and only found someone saying to use the :after option in add_column, but it doesn't do anything. then I looked in the rails api docs and found no such option. 回答1: After option works well for me add_column :table_name, :column_name, :type, :after => :column_name Also look at this

How to use Sprockets 2 with Rails 3.0.x

我们两清 提交于 2020-01-03 17:14:31
问题 I'm trying to use these gists to get Sprockets 2.0beta to work with a Rails 3.0.5 app in a similar way to how it works natively in Rails 3.1. Failing thoroughly so far--my app is finding the correct routes and files, and loading the initializer that extends Sprockets::Environment, but it's not parsing the //= require 'phu' lines in my application.js. Can anyone enlighten me about Sprockets 2 with Rails 3.0? 回答1: I have used the same gists as a basis, and it works fine. I have made some

How to use Sprockets 2 with Rails 3.0.x

孤者浪人 提交于 2020-01-03 17:14:17
问题 I'm trying to use these gists to get Sprockets 2.0beta to work with a Rails 3.0.5 app in a similar way to how it works natively in Rails 3.1. Failing thoroughly so far--my app is finding the correct routes and files, and loading the initializer that extends Sprockets::Environment, but it's not parsing the //= require 'phu' lines in my application.js. Can anyone enlighten me about Sprockets 2 with Rails 3.0? 回答1: I have used the same gists as a basis, and it works fine. I have made some

how to get response of email sent using sendgrid in rails app to save in database

♀尐吖头ヾ 提交于 2020-01-03 17:06:48
问题 I have sent email through rails app using sendgrid and actionmailer, I also received the mail. But I want status of the email sent (open,deliver,bounce..) of sendgrid in my rails app so that that response of particular email i can save in my database. I have followed: https://github.com/stephenb/sendgrid for sending email and it worked for me. 回答1: To get status of sent email, use sendgrid webhooks as described here Once this is setup, sendgrid will notify your url for the following events:

How to edit a serialized hash column in form textarea

独自空忆成欢 提交于 2020-01-03 16:22:25
问题 I have a serialized column in Company model: class Company < ActiveRecord::Base serialize :names Ideally I want it to store different names like this in the database: --- short: bestbuy long: bestbuy ltd. Currently in my company#edit page, I have a text area for it: <%= f.text_area :names %> If I have that YAML in the database, it will be displayed in the browser as: {"short"=>"bestbuy", "long"=>"bestbuy ltd."} However when I submit it, in the database it became: --- ! '{"short"=>"bestbuy",