RailsCasts Pro episodes are now free!

Learn more or hide this

Recent Comments

Avatar

HI

http://binaryhash.wordpress.com/2014/06/20/how-to-setup-secured-ssl-on-nginx/

I posted one SSL setup with nginx

May it will be helpful

if any question you ask me

Avatar

Ryan, can you shed any light on how you would go about using Doorkeeper (or something similar) to implement separate authorization and resource servers? I'm trying to build one authorization server that can handle oAuth2 for all of our resource servers (instead of trying to implement the authorization server on each of those endpoints). It seems like Doorkeeper is designed for the scenario where the resource and authorization servers are one in the same.

Awesome video and awesome service btw.

Avatar

In rails 4 using "view_context" works. Thank you.

Avatar

I have implemented this using the following:

jQuery ->
facilities = $('#call_transfer_from_id').html()

$('#call_region_id').change ->
region = $('#call_region_id :selected').text()
options = $(facilities).filter("optgroup[label=#{region}]").html()

if options
  $('#call_transfer_from_id').html(options)   
else
  $('#call_transfer_from_id').html($(options).attr('selected',true))

This works fine when changing the region. But when I need to edit the record and the form loads and I want to change the facility, all facilities are listed grouped by region whereas I'd like to have it constrain the facilities on page load. How can I combine .change and on load or document ready within this function so when I edit a record and the page loads I only see the facilities specific to that region?

Avatar

I don't like this approach and prefere to use Mercury Editor which you've showed in this railscast: http://railscasts.com/episodes/296-mercury-editor

Avatar

Hey
$ ruby -v
ruby 2.0.0p481

$ rails -v

Rails 4.1.5

I got some problem with

ruby
params.require(:article).permit(:name, :content, :published_on, :tags, :properties)

When I tryed to do a update, It leaved :tags out. It is becaus it expect a sting, not a array

This is the fix

ruby
params.require(:article).permit(:name, :content, :published_on, :properties, tags: [])
Avatar

You are correct, Heroku requires a separate worker dyno to launch background jobs.

You can use the Workless gem, which creates and kills a worker when DelayedJob is called. Heroku will only bill you the uptime ($0.05/h), not the full $35/m.

Avatar

After a lot of trouble shooting, I am stuck in this error, any ideas how to fix it?

** [out :: production.foo.com] Version '1:4.0.48-1~precise1' for 'libapache2-mod-passenger' was not found
** [out :: production.foo.com]
command finished in 4405ms
failed: "/bin/bash -l -c 'sudo -p '\''sudo password: '\'' bash -l /tmp/install_packages postfix build-essential git-core libxslt-dev ntp postgresql-client libpq-dev subversion curl autoconf bison ruby zlib1g-dev libssl-dev libreadline6-dev libxml2-dev libyaml-dev apache2 libapache2-mod-proxy-html libcurl4-openssl-dev libapache2-mod-xsendfile apache2-mpm-prefork apache2-prefork-dev libapache2-mod-passenger=1:4.0.48-1~lsb_release -sc1 collectd libperl-dev monit postgresql-9.1 openjdk-7-jdk unzip python-django python-django-tagging python-cairo python-memcache memcached uwsgi uwsgi-plugin-python uwsgi-core sqlite3 bzr zip mongodb-10gen haproxy ec2-ami-tools'" on production.foo.com

I tried running gem install passenger but didnt fix it. Help please!

Avatar

Thank you for your solution!
Cropper.rb have class Cropper < Thumbnail
so
processors => [:cropper, :thumbnail].
This code works perfect.

Avatar

Just wanted to thank you for this even after 6 months. My main problem was the data not persisting and I finally looked at the console to see that it was an issue not having csrf-tokens.

Avatar

This is not an error from the doc. Indeed, "require_tree ." means that the manifest requires the file dans the subfiles (the "tree") in the current directory (the "." means current directory).
And the lib and vendor directories aren't subdirectories of the current directory.
So your way to do it is good ;)

Avatar

entering dummy card number 4111111111111111 and cvv 123 solved the following issue for me:

Stripe error while creating customer: You passed an empty string for 'card'. We
assume empty values are an attempt to unset a parameter; however 'card' cannot b
e unset. You should remove 'card' from your request or supply a non-empty value

Avatar

I have a doubt here. I have a profile model that has two image fields. Do I need to create two uploaders, one for each image field ? I can get this to work with carrierwave direct. Can anyone help me please ?

Avatar

Thanks Man! This is what I was looking for one of my projects... :)

Avatar

Great example! Is there a way to control macros in xls files?

Avatar

provider :facebook, ENV['FACEBOOK_APP_ID'], ENV['FACEBOOK_SECRET']

how to assign the values to facebook appid and facebook secret

plz let me know
thanks

Avatar

Pjax library has changed

First you have to call the new pjax function like this in the coffeescript file:

$(document).pjax('a[data-pjax]', '#pjax-container')

Notice that the div container is now a normal div with an id "pjax-container"

Avatar

Is it even sure that one has an perfomance plus from memcache in comparison to filecache store, if one has loads of RAM (40..45GB spare for caching) and Linux' disk cache strategy already putting files in RAM?

Avatar

Having conflicts between current controllers and active admin controllers.. when I sing in both admin section and normal sections, public activity is taking normal section current user though I updated through admin section.

How to fix this

Avatar

I configured my model with tracke like the following ..

tracked owner: ->(controller, model) { controller && controller.current_user}

and when I try to update my model from admin section (I am using active admin) , it does not update current user as owner in the database .

I found the issues is controller is having nil value. how to fix this issue

Avatar

Can I use render_activities(@activities) in rabl to display json content, otherwise any approach of rendering activities in json format

Avatar

Hi all,

What might have been obvious to some but was not to me was the necessity to pay on Heroku a worker (35$) to have the queue taken care of if I'm not mistaken.

https://devcenter.heroku.com/articles/delayed-job

Best

Nicolas

Avatar

when i rake db:migrate, it does not work, nothing happens

Avatar

Mocking a third party API is a very bad practice. However you can replace the mock with stub and raise the exception.

Avatar

Ahaa! I am having exactly this problem (that future ajax submits cause duplicate records) - what exactly do you mean by "get that id back from the server and add that hidden input"? What command would I use to pull the id? And would I add that input into the form?

Avatar

Receiving console error:

Error while processing route: entries undefined is not a function TypeError: undefined is not a function at RandomRaffle.EntriesRoute.Ember.Route.extend.setupController

and

undefined is not a function TypeError: undefined is not a function
at RandomRaffle.EntriesRoute.Ember.Route.extend.setupController

when I add RandomRaffle.Entry.find() to my routes. Any ideas?

Avatar

I am having the same issue! Could you elaborate further on how you solved it?

Avatar

Thanks for the video! I'm using Rails 4.1 and still found this to be very helpful with a few tweaks. I used the Gem instead of the plugin recommendation.

Avatar

Put this in the for what it's worth category, for Postgresql, the
rails g migration add_omniauth_to_users provider uid should be
rails g migration add_omniauth_to_users provider uid:integer otherwise I was getting a
Error: operator does not exist: character varying = integer.

I had to put several casts together to get an API providing OAuth2, and a devise client to use it with Omniauth, but good job putting the important bits out there.

Avatar

Could anyone managed to make this work?
I need to implement live update in a new project. I updated the source code provided with this railscast to work with rails 4 but it doesn't.
Seems like the javascript isn't triggered when a message comes in

Avatar

One comment: the persisted? public instance method defaults to return false.

Avatar

Can someone help me with this?

Extracted source (around line #3):
/app/models/product.rb:17: syntax error, unexpected $end, expecting keyword_end

class ProductsController < ApplicationController
def index

3 @products = Product.order(:name)

respond_to do |format|
format.html
format.csv { send_data @products.to_csv }

Avatar

Thank you Dave that sorted out my ongoing problem

Avatar

Has anyone had any success getting this to work on Heroku? I have it set up, along with redis-cloud, and am able to get pub/sub working, but I need some advice on how to set up my pool size and puma threads...I very quickly reach the connection limit on the free tier of my redis-cloud account as well. Hoping someone has some experience with this.

Avatar

For some reason I never connect to the database. Verified that it was populated withe seed data. However the seed data never displays neither is any input added. Any suggestions?

Avatar

I read the GitHub issue comment about the deprecation of the border-radius mixin. With Bourbon 3.0 you should use the standard CSS border-radius: 6px;.

Avatar

This doesn't seem to work at all - file download or not. No matter what I do - even with the most basic example 100% identical to the shown source code - I get a "can’t be opened" error with Numbers (have not tried with windows). Just going to have to find a different solution entirely.