Questions tagged [ruby-on-rails]
Ruby on Rails is an open source full-stack web application framework written in Ruby. It follows the popular MVC framework model and is known for its "convention over configuration" approach to application development.
ruby-on-rails
27,226
questions
179
votes
4
answers
60k
views
Ignoring time zones for Postgres timestamps
I'm dealing with dates and times in Rails and Postgres and running into this issue:
The database is in UTC.
The user sets a time zone of choice in the Rails app, but it's only to be used when getting ...
413
votes
7
answers
123k
views
What is the difference between <%, <%=, <%# and -%> in ERB in Rails?
Can some one please describe the usage of the following characters which is used in ERB file:
<% %>
<%= %>
<% -%>
<%# %>
what's the usage of each one ?
286
votes
14
answers
145k
views
Is Ruby pass by reference or by value?
@user.update_languages(params[:language][:language1],
params[:language][:language2],
params[:language][:language3])
lang_errors = @user.errors
logger....
244
votes
6
answers
196k
views
Override devise registrations controller
I have added a field to the sign-up form that is based on a different model, see How do I use nested attributes with the devise model for the gory details. This part is working fine.
The problem now ...
362
votes
7
answers
313k
views
raw vs. html_safe vs. h to unescape html
Suppose I have the following string
@x = "<a href='#'>Turn me into a link</a>"
In my view, I want a link to be displayed. That is, I don't want everything in @x to be unescaped and ...
291
votes
38
answers
291k
views
SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
I am using Authlogic-Connect for third party logins. After running appropriate migrations, Twitter/Google/yahoo logins seem to work fine but the facebook login throws exception:
SSL_connect returned=...
257
votes
19
answers
177k
views
WARNING: Can't verify CSRF token authenticity rails
I am sending data from view to controller with AJAXand I got this error:
WARNING: Can't verify CSRF token authenticity
I think I have to send this token with data.
Does anyone know how can I do ...
207
votes
7
answers
81k
views
config.assets.compile=true in Rails production, why not?
The default Rails app installed by rails new has config.assets.compile = false in production.
And the ordinary way to do things is to run rake assets:precompile before deploying your app, to make ...
1063
votes
11
answers
230k
views
Understanding the Rails Authenticity Token
What is the Authenticity Token in Rails?
992
votes
51
answers
436k
views
Can't find the 'libpq-fe.h header when trying to install pg gem
I am using the Ruby on Rails 3.1 pre version. I like to use PostgreSQL, but the problem is installing the pg gem. It gives me the following error:
$ gem install pg
Building native extensions. This ...
647
votes
6
answers
248k
views
How to use concerns in Rails 4
The default Rails 4 project generator now creates the directory "concerns" under controllers and models. I have found some explanations about how to use routing concerns, but nothing about controllers ...
105
votes
13
answers
77k
views
ExecJS::RuntimeError on Windows trying to follow rubytutorial
UPDATE: Colin's suggestion of removing the line //= require_tree . has fixed the issue.
I have wasted over 2 days trying to follow every suggestion out there and fix my issue. I am trying to follow ...
1214
votes
15
answers
336k
views
How to understand nil vs. empty vs. blank in Ruby
I find myself repeatedly looking for a clear definition of the differences of nil?, blank?, and empty? in Ruby on Rails. Here's the closest I've come:
blank? objects are false, empty, or a ...
536
votes
33
answers
315k
views
Error installing mysql2: Failed to build gem native extension
I am having some problems when trying to install mysql2 gem for Rails. When I try to install it by running bundle install or gem install mysql2 it gives me the following error:
Error installing ...
286
votes
18
answers
270k
views
Fully custom validation error message with Rails
Using Rails I'm trying to get an error message like "The song field can't be empty" on save. Doing the following:
validates_presence_of :song_rep_xyz, :message => "can't be empty"
... only ...