Figured it out...go into TextMate's Bundle Editor (???B). Click triangle to expand "CSS" in list on left. Select "Insert Color..." and add "source.scss, " to the Scope Selector field. So Scope Selector now reads: "source.css, source.scss, meta.tag string.quoted -source". Then Bundles>Bundle Editor>Reload Bundles. ??C will now bring up color picker in SCSS files as it did in CSS files before.
Wanted to mention that vendor-prefixed properties should always go before non-prefixed properties in css, otherwise some weirdness can occur. (e.g. put -webkit-border-radius above border-radius).
Hi everyone! i made everything as the episode said, but the AJAX its not working. I removed the respond_to block, doesnt worked, also i added the format.js line that Jamil said, but also didnt worked.
Also added the two lines of Mike Bethany, and nothing... Please someone that could help me. Thanks!
it's interesting to hear you say why you suggest not using notifications for app logic. the reasons you listed for not using it are the exact reasons that i want to use it for my app logic. :)
i've got a blog post from yesterday that talks about the scenario that I'm trying to solve and how I would have used the event aggregator pattern if i were building a .net / winforms application. the notifications system is an event aggregator built right into rails, and is perfect for what I need.
I'm not sure if you are still looking for the answer, but as I just went through this episode and I am going to use a similar functionality with subdomains, as you need, I guess I know the answer for your question.
First of all, you can not expect to have in return of _path helper methods anything with the host. Instead use the _url helper methods. That will lead you into the 2nd point.
Based on the root_url(:subdomain => @blog.name) used in the episode and thanks to the overridden url_for helper you can use the subdomain key in the options of any _url helper methods. Here we go:
I think you could also override blogs_articles_url helper method to be consistent with using nested resources way of creating urls. The below code is just an idea and should be re-factored to use all functionality of blogs_articles_url helper method, but for simplicity I put the below.
ruby
defblogs_articles_url(options = nil)
if options.kind_of?(Blog)
articles_url(:subdomain => options.try(:subdomain))
elsesuperendend
I think I would personally prefer to use articles_url with :subdomain option.
I wish I could delete the post right above. It was a bad typing problem.
But I have another problem, a real one this time: flash messages are not working properly. I'm using Devise and everything is ticking right about the user, but I'm experiencing some funny behavior. When I create a new resource that is accessible through a subdomain, at the main domain, and redirect right after to this new resource, the flash message persists until I go to the main domain.
Beyond that, other flash messages, like editing this resource, don't appear at all.
Any ideas? I'm using Rails 3.0.7 and did everything that our best buddy Ryan did.
As many others have said without your efforts I would have spent way too much time on this - if anyone gets prawn up and working with Rails 3X let me know.
Has anyone else had problems with bcrypt in windows?
Using rails 3.1 beta, and looking at my sqlite3 db, password hashes are not being saved.
Also is the bundle command mentioned just "bundle install"? or something more?
Hi Ken,
you could use the above mentioned compass for that. Compass nicely integrates with rails but you can use it without it as well. You will need to run a watch process from the terminal though to monitor changes to your sass/scss files that then get compiled into css-stylesheets on the fly. Find out more about it here: http://compass-style.org/install
Wowza. I ran across this screencast after fighting with the learning curve on JQuery, Rails3, and who knows what else. An absolute lifesaver. I've liked your screencasts before, Ryan, but this one got me to donate some $$$ to you. Huge thanks.
I think at that point I would use a combination of techniques - The inherited files could also include a partial of the common elements, and a partial of the added elements - that way you could override only the added elements.
As a newbie to Rails this is very exciting, but I am wondering if there is a way to dry this up a little.
With the example, if you copy and override the side partial four times, in four different locations, then that is four places you will need to edit if you make changes to any of the links...
I ask you a little clarification: in template inheritance if I put a new link into the application/_side.html.erb partial I'll view it into all children views because they are "extended" but in the episode the view is simple ovverridden (copied and modified), am I right ?
So, is it a "template inheritance" or a "template override" ?
@Amr: you'd need to create a directory under 'views' for each of the subdomains.. (note that you can decide yourself how to structure your custom view_path, this way you can reflect whatever directory structure you like..)
I'm upgrading our Rails 2.3.11 app straight to 3.1 and my old tableless models don't work anymore (as per screencast #193). This stuff in this railscast looks nice and clean but I'm a little confused why no one else is coming up against the problem of no longer getting access to associations and the SQL Column benefits of the old way.
Is there some ActiveRecord goodness we can include/extend?
If not, the actual problem we have is that as of Rails 3.1 the tableless models are trying to hit the DB looking for "tablelesses" when initializing etc.
Does anyone have any good suggestions on how to use this if your html/css coder doesn't use rails? Before, we just created a folder in "public" called "mockups", which would use the same stylesheets, images, and javascripts as the app. But now, with this asset pipeline, I have to figure out a way to keep our streamlined integration. How do some of you handle this?
You said in the video that you would put a link in the show notes to show how you got the colour wheel working with the sass bundle, unless I'm mistaken I can't see it. Any chance you could let us know how to get it to work?
Great screencast I can't wait start using Sass in upcoming projects. Just a quick note though, I noticed you put the non vendor prefix at the beginning of your border-radius mixin. It's recommended to put the non vendor prefix at the end. Here's an article explaining what I mean.
I'm thinking on a viable solution for this since David's starting keynote. This =depend_on is a good idea, but having two separate lists (one for @import and another for depend_on) is not.
However, we can do it in a different way.
We can put any variable declarations, mixins, functions to a separate file we can depend on, then we can @import them in every single .scss file, and then we can use =require_tree . in application.css.
Rules of thumb:
As Ryan mentioned, .scss files get rendered separately, therefore separating declarations from actual @includes doesn't work in sprockets natively.
We can @import declarations to every single .scss file.
However, while =require'd files can come either from app/assets, lib/assets, and vendor/assets, @import doesn't know the trick. It doesn't even know about Sprocket's require magic (using wildcards, requiring trees, maintaining depends).
=require_tree load sequence is defined by the operating system, therefore we can't rely on it.
However, =require and =require_tree doesn't load files which are already imported. Therefore use specific =requires for files where ordering is important, and let =require_tree . to do the dirty work.
It looks like we'll have at least a plugin to handle this situation, which might be migrated to sprockets eventually, but for the time being we don't have anything similar.
First of all, thanks a lot for all those great episodes... i've been watching them all for a long time now, and this is my first question.
Let's say i have a setup like that:
Item model, has a name field as required by the tokenizer jQuery plugin:
has_many :item_components
has_many :components,
:through => :item_components,
:source => :component,
:class_name => 'Item'
Item component model, also has a quantity field:
belongs_to :item,
:foreign_key => :item_id,
:class_name => 'Item'
belongs_to :component,
:foreign_key => :component_id,
:class_name => 'Item'
You can picture that models setup as a recipe self-referential tree. The tokenizer solution works great until i want to add the "quantity" into the view... The thing is that i'd like to be able to include it (and make it editable at the same time, but that's another issue). But this quantity field is on the ItemComponent model, not on the Item model... So how can my tokenizer can be aware of it?
Thanks a lot for your time, and keep up the good work!
Kind regards,
Pierre.
just to add another issue using webrick in localhost dev..
when the buyer hit returns... Paypal send all information about the transaction...
Paypal returns a long GET URI , too long for standard webrick processing ....
we can add rm = 2 in the values passed to Paypal and get a POST returned but in this case it should be routed to a :post transaction create , and not to Product index as in the cast....
if you need to recreate the dev db , ( migrate / seed categories-products) it raises an issue :
the cart_id is used as the invoice_id , so it's already paid in the Sandbox ...
should it be better to generate the cart_id like the migration?
( based on Time_now + cart_id ) ??
Thanks a lot once again very clear
.. had to tweak a little bit the code to handle Rails3 [ version.current = 3.0.7 )
( get rid of deprecated code + link_to =post , changed to button_to )
running fine
With an existing application it was useful to automate some of the heavy lifting converting stylesheets to scss. Here is a blog post I found which provides the command line tool sass-convert syntax.
Here's an update:
Thanks, Ryan! This series helped me a lot to migrate to Rails 3. It was not as easy as I thought.
Figured it out...go into TextMate's Bundle Editor (???B). Click triangle to expand "CSS" in list on left. Select "Insert Color..." and add "source.scss, " to the Scope Selector field. So Scope Selector now reads: "source.css, source.scss, meta.tag string.quoted -source". Then Bundles>Bundle Editor>Reload Bundles. ??C will now bring up color picker in SCSS files as it did in CSS files before.
I second this request.
Another great screencast Ryan, thanks.
Wanted to mention that vendor-prefixed properties should always go before non-prefixed properties in css, otherwise some weirdness can occur. (e.g. put -webkit-border-radius above border-radius).
Hi everyone! i made everything as the episode said, but the AJAX its not working. I removed the respond_to block, doesnt worked, also i added the format.js line that Jamil said, but also didnt worked.
Also added the two lines of Mike Bethany, and nothing... Please someone that could help me. Thanks!
it's interesting to hear you say why you suggest not using notifications for app logic. the reasons you listed for not using it are the exact reasons that i want to use it for my app logic. :)
i've got a blog post from yesterday that talks about the scenario that I'm trying to solve and how I would have used the event aggregator pattern if i were building a .net / winforms application. the notifications system is an event aggregator built right into rails, and is perfect for what I need.
if you're interested, here's that blog post: How do you handle simple pub-sub, evented architecture in rails apps?
Joel,
I'm not sure if you are still looking for the answer, but as I just went through this episode and I am going to use a similar functionality with subdomains, as you need, I guess I know the answer for your question.
First of all, you can not expect to have in return of
_path
helper methods anything with the host. Instead use the_url
helper methods. That will lead you into the 2nd point.Based on the
root_url(:subdomain => @blog.name)
used in the episode and thanks to the overriddenurl_for
helper you can use thesubdomain
key in the options of any_url
helper methods. Here we go:I think you could also override
blogs_articles_url
helper method to be consistent with using nested resources way of creating urls. The below code is just an idea and should be re-factored to use all functionality ofblogs_articles_url
helper method, but for simplicity I put the below.I think I would personally prefer to use
articles_url
with:subdomain
option.Hope that helps.
When I run rake rails:upgrade:check
I get
rake aborted!
no such file to load -- test/unit/error
How can I fix it?
I wish I could delete the post right above. It was a bad typing problem.
But I have another problem, a real one this time: flash messages are not working properly. I'm using Devise and everything is ticking right about the user, but I'm experiencing some funny behavior. When I create a new resource that is accessible through a subdomain, at the main domain, and redirect right after to this new resource, the flash message persists until I go to the main domain.
Beyond that, other flash messages, like editing this resource, don't appear at all.
Any ideas? I'm using Rails 3.0.7 and did everything that our best buddy Ryan did.
Check out the Selenium IDE plugin for firefox. It's awesome for testing and you can use it against any website/server.
http://seleniumhq.org/download/
Thanks Jamil - that fixed my problem
Thanks :)
Great Screencast
However I run into problems. I get "Routing Error" "No route matches "/auth/failure"" when doing the twitter login. I have registered my app url as http://127.0.0.1 and the callback as http://127.0.0.1:3000/auth/twitter/callback.
Application keys are correct(and I do get to click the twitter authorize button so that should be fine)
Anybody knows why???
im using rails 3.1 rc2 and this error appear & hangs the webrick web server.
The switch --print-media-type, is not support using unpatched qt, and will be ignored.
has any1 encounter this issue?
As many others have said without your efforts I would have spent way too much time on this - if anyone gets prawn up and working with Rails 3X let me know.
Has anyone else had problems with bcrypt in windows?
Using rails 3.1 beta, and looking at my sqlite3 db, password hashes are not being saved.
Also is the bundle command mentioned just "bundle install"? or something more?
The bcrypt site says:
You
Very useful. Now I just need to go back and look at your episode on adding your own custom gem to another app.
I think the RailsCast are very illustrative, but all of them are buggy. All tutorials that I did until today had a bug or issue wasting valuable time.
This tutorial has a big issue:
uninitialized constant SessionController
I don't now what to do this time. Any idea to solve this?
Hi Ken,
you could use the above mentioned compass for that. Compass nicely integrates with rails but you can use it without it as well. You will need to run a watch process from the terminal though to monitor changes to your sass/scss files that then get compiled into css-stylesheets on the fly. Find out more about it here:
http://compass-style.org/install
Cheers J.
Wowza. I ran across this screencast after fighting with the learning curve on JQuery, Rails3, and who knows what else. An absolute lifesaver. I've liked your screencasts before, Ryan, but this one got me to donate some $$$ to you. Huge thanks.
"Nested Inheritance"?
That's really useful thanks
I think at that point I would use a combination of techniques - The inherited files could also include a partial of the common elements, and a partial of the added elements - that way you could override only the added elements.
As a newbie to Rails this is very exciting, but I am wondering if there is a way to dry this up a little.
With the example, if you copy and override the side partial four times, in four different locations, then that is four places you will need to edit if you make changes to any of the links...
Or is this not a real world practical issue?
This is awesome!
this + inherited_resources + (simple_form || formtastic) = scaffolding--
:)
Kudos! Great screen cast as usual. At 8:20, it should be "over-rode" not "over-rid" :o). Thanks and cheers!
It's "template override", but the controller inherits the template from the parent controller
Hi Ryan, many thanks for the screencast !
I ask you a little clarification: in template inheritance if I put a new link into the application/_side.html.erb partial I'll view it into all children views because they are "extended" but in the episode the view is simple ovverridden (copied and modified), am I right ?
So, is it a "template inheritance" or a "template override" ?
Many thanks
@Amr: you'd need to create a directory under 'views' for each of the subdomains.. (note that you can decide yourself how to structure your custom view_path, this way you can reflect whatever directory structure you like..)
Great screencast.
Just wondering about last section, what if I wanted to use a layout for each subdomain this way? where to put layouts files?
Thanks Ryan!
Hi Ryan,
Thanks again for the Railscast.
I'm upgrading our Rails 2.3.11 app straight to 3.1 and my old tableless models don't work anymore (as per screencast #193). This stuff in this railscast looks nice and clean but I'm a little confused why no one else is coming up against the problem of no longer getting access to associations and the SQL Column benefits of the old way.
We use things like:
column :option, :string, "Default"
and
has_many :areas
accepts_nested_attributes_for :areas
Is there some ActiveRecord goodness we can include/extend?
If not, the actual problem we have is that as of Rails 3.1 the tableless models are trying to hit the DB looking for "tablelesses" when initializing etc.
Thanks,
Matt
Does anyone have any good suggestions on how to use this if your html/css coder doesn't use rails? Before, we just created a folder in "public" called "mockups", which would use the same stylesheets, images, and javascripts as the app. But now, with this asset pipeline, I have to figure out a way to keep our streamlined integration. How do some of you handle this?
Hi Ryan,
You said in the video that you would put a link in the show notes to show how you got the colour wheel working with the sass bundle, unless I'm mistaken I can't see it. Any chance you could let us know how to get it to work?
Many thanks, love the screencasts.
That's why he is a ruby hero =)
Or
It appears rails --pre is broken at the moment. If you get an error along the lines of
Try this
See this stackoverflow question for more details:
;-)
For anyone who wants to add api key on every request with ActiveResource see my hack here => http://stackoverflow.com/questions/2918419/add-api-key-to-every-request-in-activeresource/6124110#6124110
If you are better solution please send me ! With Rack Middleware for example... => http://stackoverflow.com/questions/6046705/add-api-key-on-every-request-with-rack-middleware
Enjoy
Great screencast I can't wait start using Sass in upcoming projects. Just a quick note though, I noticed you put the non vendor prefix at the beginning of your border-radius mixin. It's recommended to put the non vendor prefix at the end. Here's an article explaining what I mean.
It appears rails --pre is broken at the moment. If you get an error along the lines of
Try this
See this stackoverflow question for more details:
What is to stop somebody from looking at the source javascript and extracting the FAYE_TOKEN manually, and using it via curl afterwards?
Thanks for the Railscast, the bits around 9:00 about debugging and the sprockets tweaks were really handy to know about.
I'm thinking on a viable solution for this since David's starting keynote. This =depend_on is a good idea, but having two separate lists (one for @import and another for depend_on) is not.
However, we can do it in a different way.
We can put any variable declarations, mixins, functions to a separate file we can depend on, then we can @import them in every single .scss file, and then we can use =require_tree . in application.css.
Rules of thumb:
It looks like we'll have at least a plugin to handle this situation, which might be migrated to sprockets eventually, but for the time being we don't have anything similar.
Hmm, I think I would do this instead of the imports:
/*
*require layout
*require projects
*/
Reasons: The files get recompiled on refresh and you don't need to specify the extension.
Been waiting for this for years. Absolutely fantastic!!! Am so pleased. Watched the 3.1 beta as well and wow!! same thing. So useful :):)
Thanks, Geoff. I was exhausted trying to figure things out.
Hello Ryan :)
First of all, thanks a lot for all those great episodes... i've been watching them all for a long time now, and this is my first question.
Let's say i have a setup like that:
Item model, has a name field as required by the tokenizer jQuery plugin:
has_many :item_components
has_many :components,
:through => :item_components,
:source => :component,
:class_name => 'Item'
Item component model, also has a quantity field:
belongs_to :item,
:foreign_key => :item_id,
:class_name => 'Item'
belongs_to :component,
:foreign_key => :component_id,
:class_name => 'Item'
You can picture that models setup as a recipe self-referential tree. The tokenizer solution works great until i want to add the "quantity" into the view... The thing is that i'd like to be able to include it (and make it editable at the same time, but that's another issue). But this quantity field is on the ItemComponent model, not on the Item model... So how can my tokenizer can be aware of it?
Thanks a lot for your time, and keep up the good work!
Kind regards,
Pierre.
just to add another issue using webrick in localhost dev..
when the buyer hit returns... Paypal send all information about the transaction...
Paypal returns a long GET URI , too long for standard webrick processing ....
we can add rm = 2 in the values passed to Paypal and get a POST returned but in this case it should be routed to a :post transaction create , and not to Product index as in the cast....
if you need to recreate the dev db , ( migrate / seed categories-products) it raises an issue :
the cart_id is used as the invoice_id , so it's already paid in the Sandbox ...
should it be better to generate the cart_id like the migration?
( based on Time_now + cart_id ) ??
Thanks a lot once again very clear
.. had to tweak a little bit the code to handle Rails3 [ version.current = 3.0.7 )
( get rid of deprecated code + link_to =post , changed to button_to )
running fine
With an existing application it was useful to automate some of the heavy lifting converting stylesheets to scss. Here is a blog post I found which provides the command line tool sass-convert syntax.