RailsCasts Pro episodes are now free!

Learn more or hide this

Recent Comments

Avatar

If your field is a datetime field instead of a date field (the example in this tutorial :published_on is a date field), then you can adjust your controller as per this answer on StackOverflow

Avatar

Has anyone figured out the issue with why chrome won't work locally with the JDK but Safari will?

ruby
OmniAuth::Strategies::Facebook::NoAuthorizationCodeError (must pass either a 
`code` parameter or a signed request (via `signed_request` parameter or a 
`fbsr_XXX` cookie)):

there's a message on chrome with "Unsafe Javascrtipt attempt to access frame with URL....... but there is no message like that in Safari.

I do have the FB.init setup properly

          FB.init({
            appId      : 'myappid', // App ID
            status     : true, // check login status
            cookie     : true, // enable cookies to allow the server to access the session
            xfbml      : true  // parse XFBML
          });
        
Avatar

I find out a easy solution. Just edit your routes.rb file like this:

match 'products/page/:page', :to => 'products#index'

But there is another problem. I got 2 different display styles (grid and list).

When I try something like this:

match 'products/grid/page/:page', :to => 'products#index', :display => 'grid'

I get the "pretty url" plus "?display=grid" =/

Avatar

You can accomplish this on the server side by building the nested object in your view. Use the "build_(association name)" method, which is provided by Active Record.

Inside the _action_fields.html.erb partial:

<%= f.label :step_height, "Step Height (in feet)" %>
<%= f.text_field :step_height %>

<% f.object.build_action %>  **HERE**

<%= f.fields_for :action do |builder| %>
  <%= render 'action_fields', f: builder %>
<% end %>

Now the fields_for :action block will execute and render the action_fields partial.

Naturally you would want to use this in the sub-nested partials as well.

Avatar

For anyone not using rails, there is one tricky bit. here:

ruby
RSpec.configure do |c|
  c.treat_symbols_as_metadata_keys_with_true_values = true
  c.around(:each, :vcr) do |example|
    name = example.metadata[:full_description].split(/\s+/, 2).join("/").underscore.gsub(/[^\w\/]+/, "_")
    options = example.metadata.slice(:record, :match_requests_on).except(:example_group)
    VCR.use_cassette(name, options) { example.call }
  end
end

The underscore method is a rails helper, but is unnecessary here because gsub(/[^\w\/]+/, "_") already takes care of any non-word character that's not a slash.

Avatar

Hi,

does anyone have a good solution to modify the will_paginate paging urls?

old:
.../products?page=2
new:
.../products/page/2/

Avatar

Storing this data means your application must meet certain security requirements. In the United States, this also means that you would most likely be legally liable if the information was ever stolen from you.

Avatar

wow awesome. how was that conference?

Avatar

With the default routing:

ruby
 resources :products

you'll get routes for #new and #edit, which aren't used in a pure JSON interface. Is there a reason for NOT doing

ruby
 resources :products, :except => [:new, :edit]

?

Avatar

To anyone proposing solutions for improving access controls, (or doing updated rairscasts)

please include a simple DRY way for seeds.rb and test fixtures/factories to operate with minimal interference. For example, my customer requires several read-only lookup tables in the database . Even though they are read-only in steady state, i'm forced to list each column name with attr_accessible in each model, just to have a simple seeds.rb file. Would be helpful to have a way to turn off all the controls in special cases like that, without having to list each attribute name for each model.

Avatar

Very nice video :)
But I must convert ~ 1.300.000 records on my database.
Know you faster metod that this ?

ruby
Article.find_each(&:save)

Thanks for reply.

Avatar

How can I use queue_classic to send emails? I can pretty much make queue_classic call any method and Queue it successfully, but when it comes the time to call an ActionMailer method or a class method that wraps an ActionMailer call, it simply Doesn't work!

is there an additional configuration needed?

PS. I can see the method being queued in the queue_classic_jobs table and then being removed, but it basically does nothing(does not send the e-mail) :(

Avatar

The github repository for redcarpet has gone away, does anyone know what's happening with it?

https://github.com/tanoku/redcarpet

Avatar

Funny. We switched from MySQL to MongoDB and Monogid about a year ago for the same basic reason they moved the other way. :)

We had SQL migrations and "strongly typed schema" as a major source of friction in a system that's quickly evolving and iterating. I miss joins but there is really only a single query in our system where it is a significant problem.

Avatar

I think creating a file like _globals.css.scss and importing it into your SASS files is more flexible than just importing them all manually in application.css.scss.

Avatar

I recommend Mongify if you want to create a branch of your app and move your data over from MySQL to MongoDB (and Mongoid). It saved my life when I migrated in that direction last year.

https://github.com/anlek/mongify

Avatar

What is better Squeel or sequel?

Avatar

Is it possible to get info inside the uploaded pdf file using this gem? example I uploaded my resume and I want get my name, contact info, etc. from that pdf.

Avatar

Thanks Ryan. I am getting "500 Internal Server Error" error after installing nginx. Not sure what I am missing, even though I am following exact steps mentioned in the web cast.

Avatar

I find this to be the most effective way for entering date and time. EVER
http://keith-wood.name/datetimeEntry.html

I tried these other solutions as well but none is as natural and efficient when you have to pick 100+ of dates and times:

I call this, Normalized units calendar
http://www.ama3.com/anytime/#AnyTime.picker.placement

iPhone Style
http://demo.mobiscroll.com/#demo=datetime&theme=default&display=modal&mode=mixed

Windows System Tray Like
http://www.eyecon.ro/datepicker/

an O.K. one
http://stefangabos.ro/jquery/zebra-datepicker/

TimePicker
https://github.com/fgelinas/timepicker

https://github.com/ChiperSoft/Kalendae

Hope these help

Avatar

Kalendae is a great alternative to including jQuery UI for just a date picker. I wrote a gem to provide as an asset for Rails 3.1+

https://github.com/sdball/kalendae_assets

http://rakeroutes.com/blog/add-kalendae-to-your-rails-app-with-kalendae-assets/

Avatar

Removing the pg gem from the gem file resolved the issue. The MySQL gem may also cause this to happen.

Avatar

this gem may me useful for twitter bootstrap users who need a time as well http://jdewit.github.com/bootstrap-timepicker/

Avatar

When i try to open the login form I get this error

Showing /app/views/users/new.html.erb where line #16 raised:

no implicit conversion from nil to integer

Anyone knows how to fix this?

Avatar

I am using the fullcalendar to generate calendar too.

Avatar

I've installed MiniProfiler with no problems, however I'm unable to find the configuration to allow more then 10 traces in the top left corder. The actual useful requests are getting "swallowed" by later smaller requests... (I can't precompile assets in order to reduce number of requests yet as I am on 3.0.x). Is such config option available?

Avatar

Thank you so much for this episode!
I'm also happy with another great jQuery plugin named fullcalendar.
It has Lots of support such as events from JSON and is updated frequently, theck it out! : )

Avatar

What would be sweeter than cancan getting down with strong_parameters under the covers?

Avatar

I would like to implement your "first case" example (with facebook) but I have been running into some issues with how to extend Ryan's method. Any help in how to setup the correct controller actions to essentially let someone merge their facebook uid into an existing user record?

Thanks in advance

-Dan

Avatar

Also of possible use: I recently had to add a monthpicker to a client's Rails project, allowing the user to select a month and a year, but no day. There's a useful add-on for this functionality here: https://github.com/thebrowser/jquery.ui.monthpicker

Avatar

I enjoyed this episode, though the second migration to populate counts for previous records didn't seem to go over so well when I ran it on Heroku. I ended up rolling back the second migration.

Avatar

How do you go about localizing the predicate fields?

Avatar

Something is wrong with your configuration then. I downloaded the source and ran the "blog_after." It works perfectly.

Avatar

FYI if you're using Rails 3 you need to change the line:

<% fields_for 

to:

<%= fields_for
Avatar

Makes sense, thanks Andrew.

Avatar

This was very helpful for me. Thanks for sharing.

Avatar

Does this gem do query_trace style logging? What's the current fancy option for that?

Avatar

When you step through migration steps, your model class might not correspond to the fields in the database for previous migrations. Let's say at a later point you change the model, and this older migration needs to run, it might fail because you've added validation logic or subsequently altered/removed a column that it's trying to migrate.

Avatar

There is an extension to jQuery's datepicker called datetimepicker I believe that adds hours and minutes to the selector. It does use a slider, but works well. Think this is it http://trentrichardson.com/examples/timepicker/

Avatar

Struct.new gives me a superclass mismatch
I fixed this by removing the < Struct.new and adding
attr_accessor :view, :date, :callback

Avatar

If you are using twitter bootstrap in your app you might find this calendar very handy: http://www.eyecon.ro/bootstrap-datepicker/ It integrates nicely with bootstrap design and seems to have the same functionality as the one from jquery ui.

Avatar

I agree. I plan to use this on my app. I'll probably check the size and if it's more than 5 items for that day will have a

<%= link_to "#{@model.size} more ...", list_of_models_path(@model) %>

Avatar

Awesome! I have all of the full screen JS calendars I've seen. This is nice and clean and can easily be customized.

Great job.