Way cool Ryan.
How about doing at least a two part series on Twitter Bootstrap? Simple form 2.0 has built-in support for it. It is great for people like me who are programmers but are design challenged :)
I am working with Spine and I have to tell you: it is amazing the combination Coffee + Spine.
Spine is write in Coffee and it is very simple to understand its source code, but I am a bit afraid about Spine's future, it doesn't seem as active as Backbone.
Underscore is a nice lib, but I think if you are using Coffee, Underscore becomes a kind of useless.
is there a way to delegate all instance variables of @template? for example, @controller, @action and others are not set within the scope of the presenter
I've got a solution but would like to have something better
ruby
definitialize(object, template)
@object = object
@template = template
@template.instance_variables.each do |var|
instance_variable_set var, @template.instance_variable_get(var)
endend
Aaron -- I have the same question. Were you able to find a solution to this? I know that the password_reset controller and edit form aren't set properly, but it isn't clear to me how to remedy this to update the identity model with a new password. Any help would be great!
I'm trying to build a chat using the private_pub,
I tracking the presence of the users using the Faye events
(http://faye.jcoglan.com/ruby/monitoring.html)
But unfortunately I find out that if I try to publish during the event I'm causing to endless loop so for doing that I should define a client on the server side (http://faye.jcoglan.com/ruby/clients.html) and again unfortunately I discovered that I don't know how to do that using private pub, can you clarify this for me?
Awesome job! You have a knack for distilling a complex (or cumbersome) process into simple pieces.
Thanks for pointing out bind has changed. I just upgraded a site and ran into that... and for pointing out there's a third (context) item to pass into a backbone event - never knew that was there - although I'm still not sure what it does. Maybe explain that in part 2!
ok, so it was a problem with my routes file. I've now copied the routes from cast #250 (thanks to Tim Fletcher) and everything works fine - without the respond_to code.
I am using devise and I am getting this error. I know it has something to do with devise or authentication tokens. Can anyone give me some advise? Here is my error.
I have put this tag in my layout
<%= csrf_meta_tag %>
Completed 401 Unauthorized
I had a problem with the users_controller as posted in the screencast. I copied it directly into my app, and on running got - undefined method `model_name' for NilClass:Class. I'm not sure if this was an issue with my routes, but rails needed a respond_to to be able to handle the "new" request. ie
on the minute 5.11 you show your development log, wich is very clean. did you clean it up by hand?
why i ask? because since rails 3.1 (i think) i get this annoying ouput on every request:
WARN Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true
as far as i search, this is a bug on webrick that i couldn't find a workaround. i also test with Thin, but there's a bunch of other information that i don't want either. i just want a clean log as you show it!
Anyone know if there's a way to remove the :id version of the url from working? For example, if someone visits /users/:username it brings them to that user's profile. If they visit /users/1 it brings them to the user with :id of 1. Is there a way to prevent this?
I decided against the Endless Page feature, and instead slightly adapted this RailsCast's code to provide a "Show more results" link, which would append results in much the same manner, but instead by click rather than reached-bottom-of-page detection.
The main change is the addition of the prepend line in products.js.coffee:
products.js.coffee
jQuery ->
if $('.pagination').length
$('#append_and_paginate').prepend('<a id="append_more_results" href="javascript:void(0);">Show more products</a>');
$('#append_more_results').click ->
url = $('.pagination .next_page').attr('href')
if url
$('.pagination').text('Fetching more products...')
$.getScript(url)
Regarding the view, I only added a surrounding div:
And in products/index.js.erb I just changed the remove line to $('#append_and_paginate').remove(); so that both the "Show more results" link and pagination is removed when no more results are available.
Of course some css had to be added to make things look nice.
But anyway, the cool thing about this approach is that the "Show more products" link is only added by Javascript (hence only if Javascript is present and enabled). The click handler is bound to the DOM element with id="append_more_results", which is the id of the link tag that is prepended.
My problem is that I tried everything from your comments to make emails being sended but nothing works.
WebBrick says that email was sent, so what can be wrong?
I have a respond_to block in the index action of my controller, so I had to add format.js to render the RJS template associated with this action (i.e. /app/views/products/index.js.erb):
History option is enabled for my model and when I update the slug, friendly_id_slugs slug is not getting updated. so when I create new record with the same title it is throwing uniquness error.. Please help me on this...
In the episode description:
With HTTP response headers you can the cache in the user's browser and proxies. Etags, Last-Modified, Cache-Control and Rack::Cache are all covered here
Thanks @Swart, I was getting auth/failure?message=invalid_response message. The RailsCast code was updated but not the ASCIICast version, so I was using the incorrect "user_info" key.
It would be great to see how to test controllers using warden. I mean it would always be great to see more tests, but authentication systems all have their own implications when testing controllers.
Here is underscore coffee. Is that what you were looking for?
https://github.com/jashkenas/coffee-script/blob/master/examples/underscore.coffee
Way cool Ryan.
How about doing at least a two part series on Twitter Bootstrap? Simple form 2.0 has built-in support for it. It is great for people like me who are programmers but are design challenged :)
Great episode -
Why do you have to pass both params[:id] and params[:entry] to the update action in the entries controller?
I am working with Spine and I have to tell you: it is amazing the combination Coffee + Spine.
Spine is write in Coffee and it is very simple to understand its source code, but I am a bit afraid about Spine's future, it doesn't seem as active as Backbone.
Underscore is a nice lib, but I think if you are using Coffee, Underscore becomes a kind of useless.
Ryan, talk about Spine too, it deserves.
Is it possible to create something like this:
Where
message
andmeta
- is custom keys (not in AR). And all data goes underdata
key?Thanks Ryan, Backbone and Rails is indeed an awesome combination.
I was wondering if you could provide the coffee script code in javascript code?
Great screencast, Ryan!
Thumbs up for this suggestion! :-)
is there a way to delegate all instance variables of @template? for example, @controller, @action and others are not set within the scope of the presenter
I've got a solution but would like to have something better
Aaron -- I have the same question. Were you able to find a solution to this? I know that the password_reset controller and edit form aren't set properly, but it isn't clear to me how to remedy this to update the identity model with a new password. Any help would be great!
Thanks for the episode on RABL.
It would be nice to have JSON output to be formatted in the casts. What about using https://github.com/rfletcher/safari-json-formatter ?
Hi Ryan!
I'm trying to build a chat using the private_pub,
I tracking the presence of the users using the Faye events
(http://faye.jcoglan.com/ruby/monitoring.html)
But unfortunately I find out that if I try to publish during the event I'm causing to endless loop so for doing that I should define a client on the server side (http://faye.jcoglan.com/ruby/clients.html) and again unfortunately I discovered that I don't know how to do that using private pub, can you clarify this for me?
here you can find another great explanation to what I want accomplish - http://groups.google.com/group/faye-users/browse_thread/thread/231233016e55aba2?pli=1
10x
Hey Ryan,
it's about time! Thnx a lot for this.
I think a comparison off
Knockout, Spine and ember.js would be also very interesting!
There have a much simpler syntax then backbone.js I think AND,
coffee script (spine.js) is fully "supported".
The only thing I ask me all the time, which technology has a future, not all can coexists or for me at least, it doesn't make sense.
What's your opinion on this, have you already checked out other frameworks?
cheers
Thanks Ryan. I was wondering if you had any tips for using assets in the JST templates?
Awesome job! You have a knack for distilling a complex (or cumbersome) process into simple pieces.
Thanks for pointing out bind has changed. I just upgraded a site and ran into that... and for pointing out there's a third (context) item to pass into a backbone event - never knew that was there - although I'm still not sure what it does. Maybe explain that in part 2!
The video is slightly cut-off at the end. Also the backbone-on-rails link in the show notes is pointing to another lib on github.
P.S. Great job as usual. Was meaning to play with backbone.
since i have started using backbone, i've gravitated over to Sinatra.
Not specifically with Rails, but I highly recommend reading anything by Addy Osmani:
https://github.com/addyosmani/backbone-fundamentals
http://addyosmani.com/blog/understanding-mvc-and-mvp-for-javascript-and-backbone-developers/
Derick Bailey also has a great list of resources with lots of books, blogs and videos.
Ditto. Thoughtbot PDF is well worth the coin.
Thoughbot has a pdf that I have been working through.
https://workshops.thoughtbot.com/backbone-js-on-rails
I tried this..but seem to be getting a weird error:
Completed 406 Not Acceptable in 9ms...any ideas?
I'm using rails 3.0.5...
Is there any book/s about Rails + Backbone best practices?
Thank you for making this! I'm a big fan of the RABL project and think they do an excellent job.
Also. Woot first comment.
Backbone and Rails is an awesome combination! Glad to see Backbone here on RailsCasts.
Another gem worth reviewing is backbone-rails. (https://github.com/codebrew/backbone-rails)
The scaffold generator of backbone-rails creates ready-to-run routers/models/collections/views/templates.
A note to myself, also maybe someone else will find it helpful.
If you wondered how to render resque-web inside your own layout, then use an iFrame with
src
toresque_server_url
. Works like a harm. :)ok, so it was a problem with my routes file. I've now copied the routes from cast #250 (thanks to Tim Fletcher) and everything works fine - without the respond_to code.
I am using devise and I am getting this error. I know it has something to do with devise or authentication tokens. Can anyone give me some advise? Here is my error.
I have put this tag in my layout
<%= csrf_meta_tag %>
Completed 401 Unauthorized
How do you reference a boolean field?
If the value of a boolean field is false then the field will not be included in the json response
I had a problem with the users_controller as posted in the screencast. I copied it directly into my app, and on running got - undefined method `model_name' for NilClass:Class. I'm not sure if this was an issue with my routes, but rails needed a respond_to to be able to handle the "new" request. ie
Probably only an issue if new to rails!
(Currently running rails 3.1.3)
You have mistyped:
Must be:
one question here:
on the minute 5.11 you show your development log, wich is very clean. did you clean it up by hand?
why i ask? because since rails 3.1 (i think) i get this annoying ouput on every request:
WARN Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true
as far as i search, this is a bug on webrick that i couldn't find a workaround. i also test with Thin, but there's a bunch of other information that i don't want either. i just want a clean log as you show it!
Oki my bad i found the solution in my Gemfile.
i forgot to add the new environment "staging" in the group where i declare all the gems i was using.
group :development, :test, :staging, :production do
gem 'will_paginate', '3.0'
gem 'devise', '1.5.3'
gem 'cancan', '1.6.7'
end
I hope it will help
When i had a new environment staging, i have some issues with my dependencies.
im using rails 3.2.1, with bundler 1.0
when i running
$> rails c staging
i m getting this error
/home/regis/RubymineProjects/bb-rails3/config/initializers/devise.rb:3:in `': uninitialized constant Devise (NameError)
But with
$> rails c development (no issue)
$> rails c production (no issue)
I found a trick, if i put in my application.rb
require 'devise'
require 'cancan'
require 'rails_config'
All the errors disappear why im doing wrong ?
something like
validates :password, :presence => false
is not possible: rails issue
Anyone know if there's a way to remove the :id version of the url from working? For example, if someone visits
/users/:username
it brings them to that user's profile. If they visit/users/1
it brings them to the user with :id of 1. Is there a way to prevent this?Thanks!
I decided against the Endless Page feature, and instead slightly adapted this RailsCast's code to provide a "Show more results" link, which would append results in much the same manner, but instead by click rather than reached-bottom-of-page detection.
The main change is the addition of the prepend line in
products.js.coffee
:Regarding the view, I only added a surrounding div:
And in
products/index.js.erb
I just changed theremove
line to$('#append_and_paginate').remove();
so that both the "Show more results" link and pagination is removed when no more results are available.Of course some css had to be added to make things look nice.
But anyway, the cool thing about this approach is that the "Show more products" link is only added by Javascript (hence only if Javascript is present and enabled). The click handler is bound to the DOM element with id="append_more_results", which is the id of the link tag that is prepended.
Nvm... I should have been reading better!
Hi guys!
My problem is that I tried everything from your comments to make emails being sended but nothing works.
WebBrick says that email was sent, so what can be wrong?
I have a
respond_to
block in the index action of my controller, so I had to addformat.js
to render the RJS template associated with this action (i.e./app/views/products/index.js.erb
):History option is enabled for my model and when I update the slug, friendly_id_slugs slug is not getting updated. so when I create new record with the same title it is throwing uniquness error.. Please help me on this...
is there any way to use this inside a form of active admin?
thanks!! :)
In the episode description:
With HTTP response headers you can the cache in the user's browser and proxies. Etags, Last-Modified, Cache-Control and Rack::Cache are all covered here
Should there be "used"?
Maybe you could compare/contrast between Pusher and PubNub, as long as I'm dreaming :-)
PS., also no affiliation with either of the above, just interested in using them.
A revised version of this episode would come in handy!
Thanks @Swart, I was getting auth/failure?message=invalid_response message. The RailsCast code was updated but not the ASCIICast version, so I was using the incorrect "user_info" key.
http://api.rubyonrails.org/classes/ActiveSupport/Memoizable.html
Has anyone used, this in nested form?
I am trying to use this using semantic_form_for , with a single has_many and belongs_to association
It would be great to see how to test controllers using warden. I mean it would always be great to see more tests, but authentication systems all have their own implications when testing controllers.
is this gem dead?
It sure does Dan. Awesome. I got it working now.