RailsCasts Pro episodes are now free!

Learn more or hide this

Recent Comments

Avatar

Simply updating the 'zurb-foundation' gem will not overwrite 'foundation_and_overrides.scss' or any of the other files in your assets folder.
However, if you then proceed to run rails generate foundation:install again, it will overwrite 'foundation_and_overrides.scss' (but not without prompting you for confirmation first). That generator will also modify 'application.css', 'application.js', and 'application.html.erb'.

Avatar

Nice railscast about a framework I use everyday.

About forms, to avoid the extra HTML that foundation requires, and also to have nice error rendering, I did a gem foundation_rails_helper that works with rails 3 and 4 and with foundation 3 and 4.

It has also an helper for flash messages

HTH
Seb

Avatar

If we're changing our "foundation_and_overrides.scss" file, what happens if we update zurb foundation? Will this file be overwritten?

Avatar

Can you update this video again? The version of devise used in this video isn't easily compatible with Rails 4.

Thanks!

Avatar

No way to let it work!
I really followed step by step the ASCIIcast (first part: client side) working on the Ryan's store-before app from github (master).

I used gem "jquery-datatables-rails", "~> 1.11.2" with ruby 1.9.3 and rails (3.2.1, 3.2.3) on windows.

I checked links to files in the html head page source, every link point to its file.

Now I don't know where to look for debugging again!
Maybe there is a trick I missed?

Avatar

Great video!

I am trying to use Compass with Rails 4 rc2 but just recently I got an error when I generated a new migration and I suspect that Compass is one of the reasons why I get it:
"Don't know how to build task 'assets:precompile:primary'"

Would You be so kind to give me some pointers where I should look for the solution for this error?

Best Wishes,
Matt

Avatar

Never mind.. I just understood it.

Avatar

I have been trying to understand this code for the past few hours
$('#edit_task_<%= @task.id %>').appendTo('#complete_tasks');
From where do we get the "edit-task-" div ? Please help

Avatar

Did you ever get an answer to this?

Avatar

This is a reply to a really old comment, but for anyone else that happens to run into this:

It's likely that you mistyped there. /usr/ instead of /user/ You're getting the permission error because you're trying to create a new directory from root (/) called user, instead of the existing path of /usr/local/var/

HTH

Avatar

does any one had that problem after using the rubber:create ?
ruby-1.9.3-p429/gems/excon-0.23.0/lib/excon/middlewares/expects.rb:10:in `response_call': SecurityGroupLimitExceeded => You have exceeded the number of VPC security groups allowed per instance. (Fog::Compute::AWS::Error)

Thanks.

Avatar

I agree, I would like to see an example with more than one nested form, and eventually adding an arbitrary number of nested forms via js using a form object

Avatar

I'm still getting problems with rbenv just hanging on "Installing ruby-1.9.3-p429...", I've never had any problems before, or had to alter any SSH timeouts. Any ideas?

Avatar

Could you share the code? Original isn't available anymore.

Avatar

Hi, can you share this again, link isn't available.

Avatar

I can't believe how much pain this episode saved me this week. Using traditional methods was taking me down a twisted complex path that was dramatically simplified with a form object. This is right up there with presenters and service objects as the most significant changes in mindset for me.

Avatar

Regarding the ranking and performance. Based on Postgres documentation you can store the results of the to_tsvector calls in a column, complete with weighting and then put your index on that specific column. Use a database trigger to keep that column up to date (containing as many search fields as you like and any other relevant data you'd like to throw in, author names, etc).

Calculating rank against that column will give you a relevance rank against everything you're searching for. I just implemented this approach on a huge site and the performance was lightning fast.

http://www.postgresql.org/docs/8.3/static/textsearch-features.html

See the "triggers and automatic updates" section.

Avatar

Nice Video.. I am having a problem with devise raising an error for the email can't be blank sign up. After removing the need for a email, I keep getting the error, ' ERROR: duplicate key value violates unique constraint "index_users_on_email" DETAIL: Key (email)=() already exists. : INSERT INTO "users" ("created_at", "provider", "uid", "updated_at", "username") VALUES ($1, $2, $3, $4, $5) RETURNING "id""
Thanks!!

Avatar

This gem https://github.com/evrone/factory_girl-seeds helps to minimize total spec run time by preloading records for factory_girl and then use them in spec.

Avatar

submit_to_remote no longer exist in Rails 3. Just use a submit and do as described in the video.

Avatar

Im using CentOS server through ssh, and ran:
sudo gem install passenger
rvmsudo passenger-install-apache2-module

Passenger stops installing on:
Command failed with status (): [g++ -Iext -Iext/common -Iext/libev -D_REENTRANT -I/usr/local/include -DHAS_TR1_UNORDERED_MAP -DHAS_ALLOCA_H -DHAS_SFENCE -DHAS_LFENCE -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-long-long -Wno-missing-field-initializers -ggdb -DPASSENGER_DEBUG -DBOOST_DISABLE_ASSERTS -fcommon -feliminate-unused-debug-symbols -feliminate-unused-debug-types -fvisibility=hidden -DVISIBILITY_ATTRIBUTE_SUPPORTED -Wno-attributes -o libout/common/libpassenger_common/ApplicationPool2/Implementation.o -c ext/common/ApplicationPool2/Implementation.cpp]

even after waiting for an hour no success, any idea what went wrong?

Avatar

Haha, this comment really helps me. Thank you

Avatar

It'll be something like:

CSV.parse("text you are processing", column separator, row separator)

Avatar

I had the same problem with heroku, have you found a solution?

Avatar

+1 this. I like the idea of form objects but I also like having the validations defined on the models to help make sure things like Rake tasks obey the business rules. I might try leaving the validations defined on the model and then having the form object delegate the valid? and errors() methods to the model.

Avatar

I'm running into a problem. This is a good One to one nested form, but we usually do one to many nested forms.

I've had trouble using this because I can't assign multiple things. How would I deal with features like "link_to_add" or "link_to_remove" and assigning multiple, say salaries, to a player? Unlike nested forms(with simple form) doing f.input :amount passes in ONE value for the :amount since it does not recognize that there are multiple salaries.

Avatar

she is rough around the edges; but some of you might be interested in

https://github.com/hookercookerman/form_model

Avatar

Another great cast.

Caching the comments count only seems to work with a page reload. I am using ajax to add comments and updating the count in create.js.erb: $('#comments_count').html('<%= @article.comments.size %>'); ... when using the cached version the value is not yet updated at this point?

Avatar

I also ran into this. Initially I saw nothing on screen. Changed:

<% calendar do |date| %>

to

<%= calendar do |date| %>

All is well!

Avatar

I think that in the best case, you would use a UserValidator class to perform general validations - this way it can be re-used by anything that needs to perform them.

Adding the ability to use a separate Validator class was a great change in Rails 3.. unfortunately I don't think it is used enough.

Avatar

When implementing the disable/grey-out feature on the "Draw Winner" button, the button wasn't "greying out" for me due to missing CSS styling in the layout.css.scss file.

During the first Ember railscast, I had grabbed the CSS styling per the below link. That CSS file however lacks the necessary styling for the grey-out.

Ember railscast #1 CSS
https://github.com/railscasts/408-ember-part-1/blob/master/raffler-after/app/assets/stylesheets/layout.css.scss

Ember railscast #2 CSS
https://github.com/railscasts/410-ember-part-2/blob/master/raffler-before/app/assets/stylesheets/layout.css.scss

Avatar

Here is a nice answer if your are doing controller or acceptance tests.

If you're like me and went with Rack::Test::Methods (see this post section 'Testing your API', some examples here as well), here's the solution (which was a pain to figure out ...) :

ruby
get '/api/v1/users.json', nil, 'HTTP_AUTHORIZATION' => ActionController::HttpAuthentication::Token.encode_credentials('THE-AWESOME-TOKEN')

And here is a little helper to keep things DRY :

ruby
def perform(method, url, params = {})
  token = ActionController::HttpAuthentication::Token.encode_credentials(Settings.application_api.token)
  send method, url, params, 'HTTP_AUTHORIZATION' => token

end
Avatar

How do I setup multiple environments in the .ENV file?

Avatar

There is Rails Email Preview, a gem I wrote for previewing and editing emails, with i18n and premailer support!

screenshot

Avatar

This doesn't work with airbrake :s
Do anyone know a solution to this?

Avatar

Does anyone know how to get a background image working when following this methodology? I tried setting it in the controller and in the PDF class where the margins get set. The only thing I can get to work is adding an image the full size of the page, but if I try to repeat that using Prawn's repeat method, the image covers up all the content on the pages. I can't add the image manually one page at a time because the length of the content determines how many pages there are.

Avatar

I think the proper way to prepare the fields HTML is as follows:

ruby
link_to(name, '#', class: "add_fields", data: {id: id, fields: escape_html_attribute(fields)})

and then define escape_html_attribute as follows:

ruby
def escape_html_attribute(str)
  Rack::Utils.escape_html(str).gsub("\n", '&#xA;').html_safe
end

This prevents the & in &#xA; from being escaped.

Avatar

Anyone know how to solve encoding issues with xls files generated by the simple "html" definition of a table described in the cast?

I have problems on import in LibreOffice, MS Office with special characters and umlauts (§, ö etc.).

Avatar

and how much would that cost them to operate that many memcached servers

Avatar

What did you do to get your assets to compile correctly? I think I am having the same issue.

Avatar

I've solved the problem, my problem was that the js.coffee file wasn't been included in the application.js file, that explains why the converted js worked directly on the application.js file, I had to added manually //= require ....js.coffee in the application.js file because i've removed the require_tree directive.

Avatar

Maybe you have a lib conflict, I had to try with some adjustments to the Js code and It worked for me, also i had to put it in the application.js obviously there is other problem there, but at least is working
This is my code:

$('form').on ('click', '.add_fields',
function(event) {
time = new Date().getTime()
regexp = new RegExp($(this).data('id'), 'g')
$(this).before($(this).data('fields').replace(regexp, time))
event.preventDefault()}
)

Avatar

Sometimes I feel confusing when to use Service Object vs Form Object?

Avatar

And it's good to do it that way, otherwise you start running into premature optimization.