RailsCasts Pro episodes are now free!

Learn more or hide this

Recent Comments

Avatar

Obligatory "Me too". There was a note I saw about problems with the thin web server. Switched to plain old webrick to no avail. (Of course...) Works fine in dev. Only fails in production.

Avatar

Any advantages of Mailman over Activemailer?

Avatar

Nice! But I'm wondering, is there a reason not to do authorization from scratch? In all my apps now I've got user.admin field (or UserRole model when in one that need more privileges). Then I just use a before_filter to check whether user has given privileges, and skip_before_filter in controllers where certain authorization is not needed. Are there any disadvantages of that method?

Ryan, as you're a big fan of writing authentication from scratch, I'd really like to know your opinion on whether there is a good reason to not to do this for authentication.

Avatar

Does ActiveAdmin supports sorting through a belongs_to column?

Avatar
ruby
require 'capybara/rails'

capybara/rspec was unable to load, this works fine for me.

Using Rails 3.1 on Ubuntu.

Avatar

Also the Windows testing/autotesting setup has many dead-end rabbit holes.

Avatar

Just getting things set up right. I know I had to add devkit before; and that there's some tweaking of environment variables; but no clear set of steps to follow. There is a pik devkit command, which throws an error.

Hmm. There is this,
http://puneetpandey.com/tag/how-to-install-devkit-on-windows/
which reminded me to edit devkit\config.yml and add the new ruby location, e.g.
- C:/Ruby187
- C:\Users\Ed.pik\rubies\Ruby-192-p136
- C:\Users\Ed.pik\rubies\Ruby-193-p0

Maybe that's what pik devkit was supposed to do for me!

Avatar

You must've been lucky with using delay as a Class method. I wonder what your stack is (ruby version/gem version/bundler version/rails version).

Gives a NoMethodError on Class when executing the job. The target class doesnt serialize/deserialize properly it seems. Seems like there are 3 open tickets relating to this on Github.

Avatar

Thanks for this. Helped me out on Rails 3.1

Avatar

Lower priority numbers have higher priority. It is in documentation

By default all jobs are scheduled with priority = 0, which is top priority. You can change this by setting Delayed::Worker.default_priority to something else. Lower numbers have higher priority.

Anyway great tutorial ! Thanks

Avatar

You're probably missing this line in your controller:

helper_method :sort_column, :sort_direction

This makes your 'sort_column' and 'sort_direction' controller methods available in your helper.

Avatar

Any ideas on how to use multiple pop3 mailboxes for polling?

Avatar

Could someone post an example of what the routes file for this project would look like? Im an extreme beginner, and so far can't figure out how I would configure it correctly.

-Thanks

Avatar

premailer can generate plain-text emails.

Avatar

Austin - look at this page

https://github.com/jcasimir/draper  

See "Integration with Rspec"...

Avatar

Anyone running into CSV import issues, please modify the seed.rb file as follows:

require 'csv'

puts "Importing countries..."
CSV.foreach(Rails.root.join("countries.csv"), headers: true, encoding: "ISO8859-1") do |row|
Country.create! do |country|
country.id = row[0]
country.name = row[1]
end
end

puts "Importing states..."
CSV.foreach(Rails.root.join("states.csv"), headers: true, encoding: "ISO8859-1") do |row|
State.create! do |state|
state.name = row[0]
state.country_id = row[2]
end
end

Avatar

Thanks Ryan, this is a really useful Gem.

FYI the ASCIIcast is missing a single quote in the "job_type :script" line of the first code block under the Creating Your Own Jobs section.

Avatar

Use Procfiles with foreman gem? In production export as upstart job.

Avatar

How would you do autocomplete and adding new items to the list without an association? like an open text field to add anything?

Avatar

As suggested by Jean, changing null with 'form' makes things work!

mercury.html.erb

saveStyle: 'form', // 'form', or 'json' (default json)

Avatar

Just saw that someone above has posted the same problem. Trying that solution.

Avatar

With Rails 3.1.3 this does not seem to work. Mercury is escaping parameters. Here is a part of params hash:

Processing by PagesController#mercury_update as JSON
Parameters: {"content"=>"{\"page_name\":{\"type\":\"editable\",\"value\":\"about\",\"snippets\":{}},\"page_content\":{\"type\":\"editable\",\"value\":\"{\"page_name\":{\"type\":\"editable\",\"value\":\"about\",\"snippets\":{}},\"page_content

I googled and found a similar issue: https://github.com/jejacks0n/mercury/issues/85

Avatar

Hi,

ad 1) yes, that's a Kaminari related issue. I guess it's trivial to define a paginate method, but nevertheless, there's a patch including the paginate methods for Kaminari based projects already.

ad 2) I don't understand the issue here, ie. what is "including" query do. Best to submit an issue at Github.

Avatar

Technically, it should be possibly, when you'd use the :load option. Using filters and not using :load is of course much more preferable.

Avatar

where can I find a revised and updated demo/tut for something like Rails3.1.2 "polling-for-changes" like this great but not updated screencasts: http://railscasts.com/episodes/229-polling-for-changes?view=asciicast ?

answer also here if u want
http://stackoverflow.com/questions/8760791/where-can-i-find-a-revised-and-updated-demo-tut-for-something-like-rails3-1-2-p

thank you

Avatar

I can't get any events to fire:

mercury.js
$(window).bind('mercury:ready', function() { alert("$"); });
jQuery(window).bind('mercury:ready', function() { alert("jQuery"); });
function onMercuryReady() { alert("onMercuryReady"); }

Notta :(

Avatar

Already found it, I just forgot to add "has_many :branches" to the sector model. Really stupid...

Avatar

For the "grouped_collection_select", where is the ":states" parameter created? I use this one (both @sectors and @branches are filled in the controller):

<%= f.grouped_collection_select(:branch, @sectors, @branches, :sector, :id, :branch, include_blank: true) %>

But receive an error:

(eval):1: syntax error, unexpected $end group.#<ActiveRecord::Relation

Avatar

Wouldn't it make more sense to create a $JsProduct class object in an initializer and then call new on $JsProduct in the for_mustache method?

config/initializers/js_product.rb

ruby
coffee = File.read(Rails.root.join("app/assets/javascripts/product.js.coffee"))
javascript = CoffeeScript.compile(coffee)
c = V8::Context.new
c.eval(javascript)
$JsProduct = c.eval("Product")

models/product.rb

ruby
def for_mustache
  $JsProduct.new(to_json)
end
Avatar

Did you add the CSS stylesheet to the list of assets to precompile in the production environment file?

Avatar

Guys can some one help me, I found this error:

TypeError: Object 1,our first hello world,1,1,hola,1 has no method 'each'

That error was on the 8 line of my js.erb file

var lectures = new Array();
<% for lecture in @lectures -%>
lectures.push(new Array(<%= lecture.course_id %>, '<%=h lecture.title %>', <%= lecture.id %>));
<% end -%>
function courseSelected() {
course_id = $('#course_id').val();
options = $('#lecture_id').find("option");
options.length = 1;
lectures.each(function(lecture) {
if (lecture[0] == course_id) {
options[options.length] = new Option(lecture[1], lecture[2]);
}
});
if (options.length == 1) {
$('#lecture_field').hide();
} else {
$('#lecture_field').show();
}
}

$(document).ready(function() {
$('#lecture_field').hide();
$('#course_id').live('change', courseSelected);
});

Avatar

Do some one was do it the same example with jQuery???

Avatar

Hey guys this is the solution, match "javascripts/dynamic_states" => "javascripts#dynamic_states"

Avatar

Ok, tried different things, but in the end I made an app/validators in my engine, and since all in app is (auto?) loaded, the validators from the engine are now loaded too.

Hmm.

Avatar

A mi tambien me sucede lo mismo, lo que sucede al parecer es que en el recorrido del video Ryan Bates olvido modificar las rutas.

Avatar

Agree with OP.

lib isn't autoloaded anymore.

Also, the blog post mentioned by tuscanidream doesn't explain how to get lib in engine to autoload. I think it would be good to autoload stuff from eninges, that don't belong in app. Or, make something like app/validators, which makes more sense to me.

Cheers

Avatar

Ryan
blog_after and blog_before are not updated in download package

Avatar

Incoming faxes? Wouldn't you need to have like a phone number or something? I don't think many people have the need to handle faxes.

Avatar

It's January 2012 and this comment still delivers.

Avatar

Nevermind, it automatically works if you use nested fields_for, like this (in Haml):

= labeled_form_for @song do |song_form|
  = song_form.fields_for @song.artist do |artist_form|
    ...
Avatar

From https://github.com/titanous/mailman/issues/19

Write a rake task that calls Mailman::Application.run and then use a heroku 'worker' to do this. Your rake task needs to be 'jobs:work'

http://devcenter.heroku.com/articles/queueing