RailsCasts Pro episodes are now free!

Learn more or hide this

Recent Comments

Avatar

You always seem to release just the right episode for the problem I'm trying to solve. Thanks for all the help over the years!

Avatar

Does any one know, How can I remove progress bar after uploading the file?

Avatar

If anyone's interested, I refactored Ryan's (always-awesome) approach to support editing/updating records, keep the code out of the controller, and fix a few issues. http://github.com/nerdcave/rails-multistep-form

Avatar

This validation subject is getting complex...

Let's say I validate like this:

ruby
 validates :password, :password_confirmation, :presence => true

and I use the tip above:

ruby
save!(validate: false)

This works perfectly. But If I don't want the user to confirm the password every time he saves the profile I would do like this.

ruby
validates :password, :password_confirmation, :presence => true, :if => :password

This works too. Even validates on the reset password form and ask for confirmation if the password changes on the profile. But, it has a problem. if I submit the reset password form without any value for the password or password_confirmation it won't validate the presence of :password or :password_confirmation. The password won't be updated but it'll be nice to show the validation errors for presence in this scenario.

I don't know if any one has this issue, but I would appreciate some light here.

Thanks

Avatar

I'm interested in #3, model caching + fragment caching. Why would you need to use both? I just saw the model caching video, and it looks like it solves almost all the caching problems to me, tradeoff being more memory for memcache. Can you give me an example of how you're using both model/fragment caching?

Avatar

ugh? this also generates a key for the models nuh?

Avatar

Hi great tutorial .. but have a problem with checkboxes nothing append when i'am updating??
some body has the same probleme?

Avatar

Thank you very much John! that really works.

Avatar

Yes, you could do something like this:

html
<ul class="items">
  <li>Root Item 1</li>
  <li>Root Item 2</li>
  <li>
    Root Item 3 With Children
    <ul style="display:none;">
      <li>Child Item 1</li>
      <li>Child Item 2</li>
    </ul>
  </li>
</ul>

And then open the submenu with, let's say jQuery:

javascript
$(function(){
  $("ul.items li").click(function(){
    $(this).children('ul').toggle();
  });
});
Avatar

Working with a group of developers we had some issues after doing git pull on our local machines. Just wondering if we missed something in our .gitignore to make the workflow easier?
Thanks!

Avatar

hello all. I tried to use sorcery with backbone.js. I have written API in rails but I guess I have to add the before_filter :require_login in controllers that are part of the API. The problem is that I get an error
> WARNING: Can not Verify CSRF token authenticity
> Redirected to http://localhost:3000/
> Filter chain halted as: require_login rendered or redirected
> Completed 302 Found in 2ms (ActiveRecord: 0.0ms)

Avatar

How do you use this plugin with SimpleForm?

Avatar

Awesome episode. Is there any way to hide the child and when click on the parents show them? I can use a Javascript for that?

Avatar

I have the following setup

releases.js.coffee
jQuery ->
  $('#release_anime_title').autocomplete
    source: ['foo', 'food', 'four']
_form.html.erb (release view)
<%= f.text_field :anime_title %>
application.js
//= require jquery
//= require jquery-ui
//= require jquery_ujs
//= require_tree .

Rails 3.2.12

when I type 'f', nothing gets populated. Any ideas?
I have javascript enabled on my browser.

Avatar

Thanks for posting this, Ryan should really update or add an addendum.

Avatar

The 406 occurs when you don't set the respond_to for the given format on controller.

Avatar

Miniprofiler is showing many queries selecting from pg_attribute and pg_class. These queries are not in the development log. 14 of the 20 queries on one of my pages are these pg queries. Do these queries have to be run? If not how can I prevent them from running?

I reloaded my page and it seems these are not run again, so it must be some kind of 'first time the server loads' type queries.

Avatar

Hi guys,

My "message" is a nested resource and when trying to implement the nesting for message I am getting the following error. Any clues?

Missing partial messages/message with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee]}. Searched in:
* "C:/Sites/final/cloud/app/views"

Avatar

I'm wondering how can I load a SelectBox using a restful resource.

coffeescript
Directjobs.CategoryListView = Ember.Select.extend
  contentBinding: "Directjobs.CategoriesController"
  optionLabelPath: "content.name"
  optionValuePath: "content.id"

However it does work, I'm not sure if I have to load the content to the controller first, because I have the route in this way.

coffeescript
Directjobs.Router.map (match) ->
  @route 'entries', path: '/'
  @resource "categories", path: '/categories'


Directjobs.Router.map (match) ->
  @route 'entries', path: '/'
  @resource "categories", path: '/categories'

Any Ideas?

Avatar

If anyone is looking to use Bootstrap datepicker with best_in_place, I've forked best_in_place and turned the datepicker call into an event. Bootstrap support comes built in.

If the pull request is accepted it will be a part of best_in_place.

https://github.com/straydogstudio/best_in_place

Avatar

have you solved this? I have the same problem with Korean language.

Avatar

I tried adding this method for adding grandchildren but I get the error: undefined method 'klass' for nil:NilClass passing in :image as the child_association. Could you possible post your form code?

Avatar

trying to find user friends who are using my app using koala gem but I am facing these issue and I didnot find any solution for it

Koala::Facebook::AuthenticationError in Reg_steps#show

type: OAuthException, code: 190, error_subcode: 460, message: Error validating access token: Session does not match current stored session. This may be because the user changed the password since the time the session was created or Facebook has changed the session for security reasons. [HTTP 400]

Avatar

Thanks for this! Not understanding how exactly this worked, I wasn't able to get your code to work in my app. I found this post to be helpful. Any comments on it in terms of simplicity and/or limitations?

Avatar

or you can modify your environment config to not mangle the variables when minimizing. I modified the code to "do the right thing" and worked fine for me on Heroku. Happy to help.

Avatar

Has anyone seen or created a solid example of using delete? Or even better, batch delete? Say I want to clear all entries in the example...I'm trying to use a simple call to a $scope.clearEntries function in my raffle.js.coffee file but doesn't seem to work.

Great kick off for Angular as always though, Ryan. Thanks again.

Avatar

Valkyrie looks interesting. I'm using rbenv, installing the gem, how do you get it to work from the command line as in the example?

Avatar

Ryan, you are an outstanding teacher. 1000+1 thanks for your railscasts.

Avatar

alonzorz... have you resolved this? I am running into the same problem.

Avatar

Hi @dedek, you code looks ok to me. Just make sure you are actually instantiating a task in your controller, something like this

class ProjectsController

  def new
    @project = Project.new
    @project.tasks.build
  end

  ...
end

Good luck!

Avatar

yes, after you insert a new field, find the select element and call chosen on it.
In my case it was like this:

ruby
  $('form').on 'click', '.add_fields', (event) ->
    time = new Date().getTime()
    regexp = new RegExp($(this).data('id'), 'g')
    $(this).before($(this).data('fields').replace(regexp, time))
    $('fieldset.show_person_role:last .chzn-select').chosen()
    event.preventDefault()

this is my association:

ruby
<fieldset class="show_person_role">
<%= f.association :person, collection: Person.order('people.name ASC').all, :input_html => { :class => "chzn-select" } %>
</fieldset>

I add the class chzn-select which is used to find the element.

Avatar

Is there a way to display a text field when a checkbox is checked? Say you want to add more info about that product in the join model. You check "Board Game" and you want to comment that "Settlers of Catan is a great Board Game for ages 5 - Adult" (or something like that). You also check "Toys & Games" and want to add "A Great Christmas Gift". This would update a field in the join model table called "Comments". The data in the join model would now be

ID 1
product_id 1
category_id 1
comment "Settlers of Catan..."

ID 2
product_id 1
category_id 6
comment "A Great Christmas ..."

My question is, how do you store extra info in the join model and extract that out later?

Thanks.

Avatar

Simple direct File Upload to Amazon S3 using Javascript, jQuery, Amazon S3 CORS support, Simple Form with progress bar. Designed by me in Silicon Valley and developed by Denny: https://github.com/dennybritz or https://github.com/bparanj/s3-cors-upload-rails. Enjoy.

Avatar

I'm having trouble with binding of caller. I can't start the rails server (or guard) with it installed. Any ideas on what to do about this error?

dyld: lazy symbol binding failed: Symbol not found: _RUBY_FREE_ENTER
Referenced from: .../.rvm/gems/ruby-1.9.3-p429/gems/binding_of_caller-0.7.1/lib/binding_of_caller.bundle
Expected in: flat namespace

dyld: Symbol not found: _RUBY_FREE_ENTER
Referenced from: .../.rvm/gems/ruby-1.9.3-p429/gems/binding_of_caller-0.7.1/lib/binding_of_caller.bundle
Expected in: flat namespace

Trace/BPT trap