RailsCasts Pro episodes are now free!

Learn more or hide this

Recent Comments

Avatar

Imho Angular and Ember are not in 'versus' position. They both have their use cases.

Avatar

somehow it now works out of nowhere. i think restarting the server helps!

Avatar

You know this is awesome sauce.

The most valuable thing however was

product.attributes = row.to_hash.slice(*accessible_attributes)

The thought is simple, it's mass assignment basics but would have never thought of it when importing excel files!

Super.

Avatar

Btw... I got stuck how to use https://github.com/mikepinde/angular-ui-rails
on my angularJS application. I want to handle keypress event with it, but after I follow the steps in some tutorial (blog), it seems not worked. anyone can give me some good tutorial for "how to use angular-ui-rails"?

Cheers

Avatar

http://reefpoints.dockyard.com/ember/2013/01/07/building-an-ember-app-with-rails-api-part-1.html

I just did this, pretty good. The promise of Ember, imho, is that everything runs on the client, and the server just becomes a database passing json back and forth for persistance... Ember-data still needs work from what I'm told.

Avatar

that's the million dollar question... If you find a good example, let me know...

Avatar

After trying to learn Ember for the past few weeks, starting with the peep code tutorial I can say I'm just starting to "get it." And like everyone on this post I've been reading a TON about ember vs angular. But I haven't actually tried angular. Angular is backed by google! While Ember is two guys in a room, and sure other contributors. But it's the old David and Goliath, and who doesn't want to route for the underdog?

I've also noticed the advanced js programmers tend to use Ember over angular (at least the ones I know), I can only think they have good reason. And from what I can gather it's that you can do more complex things with Ember, at greater speed, once past the learning curve.

Avatar

With this example, if we select United States or United kingdom it won't work. reason while filter state it is not able filter the value which have space. kindly someone help to get the values

Avatar

Is it possible to import past activities? My app already has a lot of data generated by the User. Curious if there is a migration or some sort of import that exists with this for implementing it into an already existing app with a lot of data.

Avatar

I was having troubles with throwing errors with ascii cast example:

@CommentPoller ->
  poll: ->
    setTimeout @request, 5000

turns out that needs to be as in the shownotes:

@CommentPoller =
  poll: ->
    setTimeout @request, 5000

I get undefined errors with the '->'

Avatar

Liked the Active::Record stuff on that blog so I've bookmarked this for later reading.

Thanks

Avatar

Yeah - I'm experiencing this too. I tweaked the code but now it appears to finds all the orders that are both in that state currently, or have at some point been in that particular state, which isn't quite working either.

Avatar

After adding a tenant_id and default_scope, where is the best place to add this to be used by Rspec tests (where all database queries are currently failing due to the tenant_id being null)? Can I put this in a single place to be applied this across multiple tests?

Thank you

Avatar

A little OT, but here's a link to SO with a way to hack Struct into a Rails project. I've just spent the morning reading up on Struct, OpenStruct, etc. and am amazed with the possibilities!

Didn't really know how to approach using OpenStruct or Struct before this episode. Thanks, Ryan!

http://stackoverflow.com/questions/2240535/how-do-i-use-hash-keys-as-methods-on-a-class/4064219#4064219

Avatar

In your ASCIIcast path is "/config/carrierwave.rb", but definitely it should be "/config/initializers/carrierwave.rb"

Avatar

Lots of comments and posts and sample apps.
Is there any sample app or post that implements user login/session?

Avatar

Is anyone using Spine? Would love to hear some comparison between Spine and Angular.

Avatar

I have installed apache-tomcat/solr server in centos , I can able to see the solr page in this link ,

http://localhost:8080/solr/

reindexing the models alos done all the log pointing to the catalina log file

how to connect the solr server to rails application

I have included sunspot.yml code here
sunspot.yml
development:
solr:
hostname: localhost
port: 8982
path: '/solr/'
log_level: WARNING
solr_home: /opt/solr
auto_commit_after_request: false
test:
solr:
hostname: localhost
port: 8981
log_level: OFF
production:
solr:
hostname: localhost
port: 8080
path: '/solr/'
log_level: WARNING
pid_dir: '/var/run'
auto_commit_after_request: false

Please help me to get resolved

Thanks in advance..

Avatar

I have installed apache-tomcat/solr server in centos , I can able to see the solr page in this link ,

http://localhost:8080/solr/

reindexing the models alos done all the log pointing to the catalina log file

how to connect the solr server to rails application

I have included sunspot.yml code here
sunspot.yml
development:
solr:
hostname: localhost
port: 8982
path: '/solr/'
log_level: WARNING
#solr_home: /opt/solr
auto_commit_after_request: false
test:
solr:
hostname: localhost
port: 8981
log_level: OFF
production:
solr:
hostname: localhost
port: 8080
path: '/solr/'
log_level: WARNING
pid_dir: '/var/run'
auto_commit_after_request: false

Please help me to get resolved

Thanks in advance..

~

Avatar

This railscasts doesn't cover how to handle config.action_controller.asset_host which is used when emailing for instance.

You want the email to link to the asset in the correct subdomain.

The solution I'm thinking to use looks like this:

ruby
config.action_controller.asset_host = Proc.new { |source, request = nil, *_|
  top_level = request.subdomain.split('.')[-1]
  domain = CONFIG['domain']
  '#{top_level}.#{domain}'
}

Though I'm not quite sure how to write a test for this.

Avatar

How does this look when you have fields in both objects? How do create from a single form? For example, I want to track two different expense types: reimbursements and donations.

Reimbursements have a description, donations have name, address, etc., but both have an amount, a receipt, a category, and belong to an account.

I'm trying the polymorphic association approach, but having trouble figuring out how to create a new reimbursement/entry with all the necessary data and associated objects.

Avatar

Hi guys, I am very very new to ROR so I really appreciate any help.

When I place the

           has_reputation :votes, source: :user, aggregated_by: :sum

in my post model, my page shows up as

"undefined method `has_reputation' for #Class:0x007fe5708753e0"

and then reloading turns it into

"undefined method `key?' for nil:NilClass"

If I take away these codes in my post model, the page will show fine then I try to click on the "up" button, and this shows up

undefined method `add_evaluation' for #Post:0x007fe57100e2c8

anyone can help me out? thank you so much

this is my post_controller

def vote
value = params[:type] == "up" ? 1 : -1
@post = Post.find(params[:id])
@post.add_or_update_evaluation(:votes, value, current_user)
redirect_to :back, notice: "Thank you for voting"
end

Avatar

FYI... Rails 4 deprecates match routes. As far as I can tell, replacing "match" with "get" in config/routes.rb makes this episode Rails 4 friendly. Maybe that is obvious, but I was surprised the 'auth/:provider/callback' route wasn't a POST.

config/routes.rb
get 'auth/:provider/callback', to: 'sessions#create'
get 'auth/failure', to: redirect('/')
get 'signout', to: 'sessions#destroy', as: 'signout'
Avatar

No, not within a .slim template, but you wouldn't really want to do that anyway. Way better to have it in its own .emblem file so you can precompile it and not even have to include emblem.js as something your browser has to load

Avatar

@Alex, thanks a million for putting this together. It makes it WAY easier to connect the dots between this and traditional JS.

Avatar

FYI, to those that have :inheritance_column set to something other than :type on the class you are calling :reset_column_information, make sure you set it again after the :reset_column_information call or it will give you the "column 'type' is reserved" error when running the migration.

This is because the class :inheritance_column setting is effectively ignored after you call :reset_column_information after the class is loaded. So, in short, assuming the Project class had :inheritance_column set to something other than :type, your migration should be:

ruby
Project.reset_column_information
Project.inheritance_column = nil #or whatever you have it set to
  Project.find(:all).each do |p|
    Project.update_counters p.id, :tasks_count => p.tasks.length
  end

Took a while for me to realize what was going on, so hopefully this saves someone some time.

Avatar

Meteor 15min, Angular 16min, backbone 32min and Ember 25min+. Meteor Wins!

Avatar

I've seen recently a Gem for creating such method encapsulation like memoization. It's called MethodDecorators, inspired by actual decorators existing in Python, you can find it on Github.

It's very interesting because of its extensive usage of metaprogramming and the way author mimics features of another programming language.

Avatar

same here..I've followed the steps to install vagrant with rails but when I try to connect with localhost:3000 on windows it takes 1-2minutes to load the page.

If I execute a curl command on the vbox though I get the page in no time.

Avatar
bash
$ sudo vim /etc/nginx/sites-enabled/default

On line 22 (I think) you will see a line that says listen [::]:80 default_server; - comment that one out. then :wq [enter] to save and close.

Then try again: sudo service nginx start. Or just don't worry about it, as the file will be deleted later in the tutorial.

Avatar

Hi Jose,

I cannot precisely answer your question regarding Travis CI. However you can find an article which covers the setup of TeamCity CI for automated headless testing of Javascript code - both Jasmine and CasperJS - in detail here:

http://www.jrubyonrails.de/2013/03/continuous-integration-for-jasmine--and-casperjs-tests.html

It might be a good starting point.

Avatar

Nice. A direct translation will be http://jsbin.com/ihuqoz/2/edit

It uses an EntriesController.

Avatar

Very true and the frontpage says it all.

A framework for creating ambitious applications

Avatar

This is true for all of them actually: Angular is build by guys with strong technical background and if one will to master it than he should understand wide variety of JS templates: factories, providers, injectors and much more.
Ember is evolving so fast that almost all documentation is out of date :)
Joosy is just one of a kind - but I think Rails world only wins from the diversity it brings into it. Again I haven't work with it because of there wasn't such a demand, but I strongly belives that it have it's layer - large scale rich applications.
If one day content generated by Joosy will be compilant with search engines it will really shine as first-class sitizen in a lots of porjects.

Avatar

ok..i've fixed this issue.but progress bar doesn't seem to finish. so you've any solution.

Avatar

Joosy seems does not as easy to use as declared.

Avatar

Is it possible to use Emblemjs in Slim templates?

Avatar

Okay, guys you want a Ember vs Angular opinion - here it is:
Angular is more general and 'address root problem that HTML was not designed for dynamic views' in a very sleek way. It's directives is awesome - if u try it once you just cant forget how beautiful they are!
But he is not ready for a big applications, imho. Just look at his nested routing solution - it doesn't have one! There is only 3rd party module in angular-ui https://github.com/angular-ui/ui-router. No surprise it's version is 0.0.1
Ember is rails-aware and and it's your friend in a middle-size applications.
My opinion that Angular is a competitor rather to Backbone than to Ember. I'll use Angular if to drop interactivity here and there and use Ember for a to have a real front-side application, but... here is the sweet part - Joosy(http://www.joosy.ws/)!
So we have solutions for small, midle, and large front-end applicatoins, isn't this wonderful? :)

Avatar

Your opinion on this is correct, it's just not worth the effort because all of the restrictions on concurrent connections. After trying many possibilities (ActionController::Live, Socket.io, Faye,... ) we decided to outsource the real-time component entirely to pusher.com - highly recommended. It takes literally minutes to set up and you don't have to worry about updating, uptime, compatibilities, scaling...

(disclaimer: not affiliated to Pusher in any way)

Avatar

Great series of casts Ryan! VERY helpful!

Thank you very much :)

Avatar

i'm running same code on my machine but this application is not working (https://github.com/railscasts/381-jquery-file-upload/blob/master/gallery-after)

i'm following all step.but images is not uploading.So plz give me your code.which you've uploaded on heroku. or give me any hint.

Avatar

Does it help SEO, in the sense that all the membership-only material is made available for search engines such as google etc to scan?

Avatar

Could someone point me to a resource to learn how to set it up so that I can use facebook authentication for an app on heroku and localhost:300 at the same time?

Avatar

You can try to implement Angular's "Hello world" in jQuery. That's where jQuery solution will be more complex, and that's why I like Angular.

I created a gist with another example: https://gist.github.com/denispeplin/5096725

This code I'm using for displaying RRD graphs of different types. I will be surprised if someone will implement same thing in jQuery with same or less amount of JavaScript code.

Avatar

+1 - when you put it like that, makes it seem very simple...