I am attempting to recreate your #17 screen cast under Rails 2.2 and am having problems. Is it possible that you have the code for the "Controllers through DB" zipped somewhere were your audience could download into a learning rails project and test? I think that I am missing too many "background" rails set-ups for my attempt to work. One of the problems I am getting is a reversal of the browser_os join in the rails application I am trying to build. Is this because I created the scaffolds in reverse order? [Even typing that last statement it looks dumb -- but what do I know?]
Thanks. I hope that you are still monitoring/responding to this railscast.
I have multiple models which I want to create. I have products and categories. The categories work like the tasks Ryan goes through in this episode, but I want products as well to be dynamically added and removed so in the partial for the category i added another partial for a product and I added helpers and extended the model.
However when I click the add category button then I get an error: missing } after property list
http://localhost:3000/shops/new#
Line 2
The buttons for removing and adding products works fine. If I remove the helpers for products then the category buttons works fine again.
Help!
Anyone who has had success using this with multiple models?
so are these new App Templates going to replace the Base Rails Apps floating around out there (eg bort, blank, etc)?...or does this new feature serve a totally different purpose? Can someone please explain? sorry, for the noob question. thanks!
Personally, I prefer more desert (http://github.com/pivotal/desert/tree/master) than engines. Actually I have switched from engines to desert earlier. If you want to known why, please read the Brian Takita from pivotallabs's own comment about the desert framework (http://pivotallabs.com/users/brian/blog/articles/459-build-your-own-rails-plugin-platform-with-desert#1115). And I really like to use desert. Now I donot follow engines any more, and donot known which new features are coming into the new engines. If somebody knows, why should choose engines than desert, please tell me why. Thanks!
Yet another great screen cast. I have one question though! What happens on moving some files to merged app, when there are already some files with same names?
It might be the case with image files in the public/images directory. And it is likely to have duplicates...
Ryan, you are truly a prince amongst mortal men. I'm really impressed and inspired by your consistency in delivering highly interesting, relevant, and pragmatic screencasts. Just wow, man. And a huge high-five!
Given that it's `system "rsync -ruv vendor/plugins/blogify/db/migrate db"` to move your migrations over.
Shouldn't it be `system "rsync -ruv vendor/plugins/blogify/public public"` and not `system "rsync -ruv vendor/plugins/blogify/public ."` to move the public files over?
@George, you're right, authentication is tricky. I think it's best if one app handles the primary authentication and the other app simply extends the user class with the methods it needs.
@AdulteratedJedi, right, there's talk that this kind of thing will be much improved in Rails 3.
@Moshi, AFAIK plugin_migration isn't included in 2.3, it is only in the Rails Engine plugin. Rsync seemed like an easy enough solution, and you'll need to sync up the public files anyway so might as well do the migrations in the same way.
In vendor/plugins/selenium_on_rails/lib/selenium_on_rails_config.rb (note the name of the plugin - if it's selenium-on-rails, you will have other errors!)
I'm following the example using Attachment Fu to allow my users to upload 1..n images. Its almost working ! However, I only upload the number of images that where originally created in the New method of the controller
3.times {@article.images.build}
Will allow me to upload 3 images.
I can add more file_field uploads, they appear on my form, I can remove them etc. Its almost like :object => statement in the helper is not creating an object . .
I do know that my virtual attribute setter in the model is only receiving the number of objects defined in the controller.
I hope that makes sense and somebody can help. New to rails so I may be making an obvious mistake. . .
Hi Ryan,
It would be too nice of you if you could include an episode for setting up RSpec for writing rspec tests. I tried to follow your video but was not able to set up rspec in the first place.. Help!
It seems this won't work with url helpers? Doing something like posts_path returns "undefined method `default_url_options’" even when including UrlWriter and UrlHelper first. Or maybe I'm missing something.... :/
Do you know how to use this to sort by more than just position? I want to sort people with drag/drop, but maintain two columns, male and female. Can u sort by, say, position and sex?
I do have Ruby 1.9 installed but I can't seem to get any gems to work with it. I'm running Rails 2.3 just fine. But I had to run it with Thin and not webrick because each request was taking 40 seconds...but I digress... :-)
@RyanB
I had to add "include Authentication" in the application_controller after following your example. No biggie. I might have messed up but anyway, just FYI.
I have the same problem as Patrick above. When you submit the form and the validations fails, none of the Credit Card fields get tagged with class="fieldWithErrors". Does anyone know how to get them to?
Thanks for this episode Ryan. I have a question here. You talked about some methods in this episode that are provided by has_many: association ( for example- cart.line_items.build, line_item.build_delivery_method, etc.. )What do you mean by that? And is there any documentation for such methods?
I will appreciate your help to make me understand this.
How can I make rails generate ALL urls to point to a valid subdomain?
Example:
personal.blog.local has a page with a url:
<%= link_to "Show blog", blog_root %>
If I follow your howto, this will work, obviously, but now my question is: how can I generate urls to, let's say the "edit" action?
<%= link_to "Show blog", edit_blog_root %> doesn't work. Kind of logical, since we didn't define it anywhere, but I still want to know how this can be done dynamically.
So the thing I'm looking for, is some kind of directive in the routes config file, that generates all kinds of default paths I can use. Something like this:
map.resources :blogs, [insert specific information here so that rails generates edit/destroy/show/etc... URLs]
in my utter despair and after hours trying and erring i turned to you and your readers with the above 70. egorbrandt Feb 11, 2009 at 06:24.
getting bold and bored i simply removed the <%= javascript_include_tag 'jquery', 'application' %> from application.html.erb. your guess is as good as was mine: it worked, and solved my original problem with the two posts (or puts).
why would removing that tag solve my problem? my confusion is even greater right now.
Thus, the commit command will be executed first, even though you gave it as the "second" argument. I don't know about the inner workings of the git method in the Rails Templates, but probably it's just a plain "def git(options)", so the arguments you provide become a plain hash with mentioned problem.
@Ryan: I think there is an issue with using both git commit and rake gems:install, since the former will use your git credentials specified in your user config, while the latter will need sudo rights.
Executing the whole script as sudo will let gems install, but will probably give you empty git committer names (as long as you do not have them specified for root as well) and of course root permissions on all your apps files.
I found a nice detail in Peter Coopers example template (see http://gist.github.com/33337), which executes gems:install with the additional :sudo option:
as a starter - and slow student - i'm often intrigued to look for the underlying code (and relations) and have it working 'my way.'
maybe you, or one of your readers could help me with the following.
after adjusting and adding the 'screencast code' to my app, there are two reviews submitted to the database... and subsequently returned on the products/show.html.erb screen. any idea how i could solve this would be welcome!
for your thoughts: putting the alert('hello') in the create.js.erb file gives me this friendly message two times.
While running "rake test:acceptance" on console I am getting this error
***************
rake aborted!
uninitialized constant SeleniumOnRailsConfig::ERB
*******************
Could you please show me links for Selenium in Rails as Am using the beta for Rails 2.2
@Chess: deleting the object destroys the attachment as well as the folder structure. Only the public/<modelname> remains.
The id/style/style.extn gets deleted.
I am trying to use Paperclip with a form_remote_for (ajax form) .. but it seems to not recognize the associated form field as being related to the paperclip generated fields.
i.e. I am using <%= form.file_field :pdf %>
and when I submit, I get a message indicating the Pdf must be set - as if it isn't being sent. I can verify it is in the params in the log and that the form is using multipart=>true
Are there known issues or extra steps I must take to get Paperclip to work with a remote form (ajax)?
@Andy, @Yitzhak interesting, it is downloading all the way for me. Try right-clicking the link and choosing download instead of having it load in the browser. You may also want to try the alternative format (for iPod).
@jeroen: One disadvantage of your solution is, that your "templates" do include one specific version of rails and included gems & plugins (Updating rails doesn't update all files in your app. E.g. the config/environment.rb or the config/initializers/* are only generated for new apps).
Also you can't use functions like ask or yes? nor can your "templates" inherit from other templates.
Hello Ryan,
Great screen cast tutorials.
I am attempting to recreate your #17 screen cast under Rails 2.2 and am having problems. Is it possible that you have the code for the "Controllers through DB" zipped somewhere were your audience could download into a learning rails project and test? I think that I am missing too many "background" rails set-ups for my attempt to work. One of the problems I am getting is a reversal of the browser_os join in the rails application I am trying to build. Is this because I created the scaffolds in reverse order? [Even typing that last statement it looks dumb -- but what do I know?]
Thanks. I hope that you are still monitoring/responding to this railscast.
This is great! Thanks for the heads up on this functionality. This has helped me with opening the flood gates of creative ideas.
Please keep up the great work.
Hi,
How do i go about adding invoice ID. and Item Title to the gateway option?
I have multiple models which I want to create. I have products and categories. The categories work like the tasks Ryan goes through in this episode, but I want products as well to be dynamically added and removed so in the partial for the category i added another partial for a product and I added helpers and extended the model.
However when I click the add category button then I get an error: missing } after property list
http://localhost:3000/shops/new#
Line 2
The buttons for removing and adding products works fine. If I remove the helpers for products then the category buttons works fine again.
Help!
Anyone who has had success using this with multiple models?
Thanks ! Very good, like all your amazing screencasts ! :)
so are these new App Templates going to replace the Base Rails Apps floating around out there (eg bort, blank, etc)?...or does this new feature serve a totally different purpose? Can someone please explain? sorry, for the noob question. thanks!
Personally, I prefer more desert (http://github.com/pivotal/desert/tree/master) than engines. Actually I have switched from engines to desert earlier. If you want to known why, please read the Brian Takita from pivotallabs's own comment about the desert framework (http://pivotallabs.com/users/brian/blog/articles/459-build-your-own-rails-plugin-platform-with-desert#1115). And I really like to use desert. Now I donot follow engines any more, and donot known which new features are coming into the new engines. If somebody knows, why should choose engines than desert, please tell me why. Thanks!
Yet another great screen cast. I have one question though! What happens on moving some files to merged app, when there are already some files with same names?
It might be the case with image files in the public/images directory. And it is likely to have duplicates...
Ryan, you are truly a prince amongst mortal men. I'm really impressed and inspired by your consistency in delivering highly interesting, relevant, and pragmatic screencasts. Just wow, man. And a huge high-five!
Another great screen cast! Can't wait to try it.
I'm not sure if Engines would work for my particular situation. Can anyone offer some advice for my current headache?
http://www.railsforum.com/viewtopic.php?id=23417
Thanks!
Really useful for dipping your toes into the 'liquid' world (sorry)
I've been struggling for about a week with URL generation which is a deal-breaker for most uses. Still no luck yet.
Anyone?
Oh wait. Nevermind... still too early for me.
Given that it's `system "rsync -ruv vendor/plugins/blogify/db/migrate db"` to move your migrations over.
Shouldn't it be `system "rsync -ruv vendor/plugins/blogify/public public"` and not `system "rsync -ruv vendor/plugins/blogify/public ."` to move the public files over?
@George, you're right, authentication is tricky. I think it's best if one app handles the primary authentication and the other app simply extends the user class with the methods it needs.
@AdulteratedJedi, right, there's talk that this kind of thing will be much improved in Rails 3.
@Moshi, AFAIK plugin_migration isn't included in 2.3, it is only in the Rails Engine plugin. Rsync seemed like an easy enough solution, and you'll need to sync up the public files anyway so might as well do the migrations in the same way.
About migrations, why the plugin_migration generator is not used.
Isn't it available in Rails 2.3 ?
Maybe is it easier to work with rsync, why this choice ?
Anyway, thanks a lot for this great episode ! :)
Hmmm, I think I prefer the way merb does it with slices...
@Binod
Here's how I fixed that error:
In vendor/plugins/selenium_on_rails/lib/selenium_on_rails_config.rb (note the name of the plugin - if it's selenium-on-rails, you will have other errors!)
Underneath "include 'yaml'", put "include 'erb'"
voila with extra sauce!
if someone want to compare the "new" rails engine 2.3 with the "old" plugin to see what has changed and what is still missing, here is the link:
http://rails-engines.org/news/2009/02/02/engines-in-rails-2-3/
again, a really good screencast.
Any thoughts on how to handle authentication? Seems like that will be a sticky point for embedding applications together to play nice.
I'm downloading now. I wonder if this is due at all to Merb and Slices and the coming merger? It sounds sort of similar from your description.
This looks very cool, thanks for the Railscast
Really Nice Article. Great Job.
Great screencast, Ryan. Good job.
I'm following the example using Attachment Fu to allow my users to upload 1..n images. Its almost working ! However, I only upload the number of images that where originally created in the New method of the controller
3.times {@article.images.build}
Will allow me to upload 3 images.
I can add more file_field uploads, they appear on my form, I can remove them etc. Its almost like :object => statement in the helper is not creating an object . .
I do know that my virtual attribute setter in the model is only receiving the number of objects defined in the controller.
I hope that makes sense and somebody can help. New to rails so I may be making an obvious mistake. . .
Thanks in advance
@Juergen
To get the flash to display I added to following to my sessions/new.html.erb
<% if flash[:error] -%>
<div id="error"><%= flash[:error] %></div>
<% end -%>
Hi Ryan,
It would be too nice of you if you could include an episode for setting up RSpec for writing rspec tests. I tried to follow your video but was not able to set up rspec in the first place.. Help!
There is a simple utility that I have used which you can use for Rails Dynamic Routes (http://rdr.rubyforge.org/)
It seems this won't work with url helpers? Doing something like posts_path returns "undefined method `default_url_options’" even when including UrlWriter and UrlHelper first. Or maybe I'm missing something.... :/
Great Work Ryan!!
Keep more of these coming!!
Do you know how to use this to sort by more than just position? I want to sort people with drag/drop, but maintain two columns, male and female. Can u sort by, say, position and sex?
at 5:12 where does come from the `y` in the `y due_date` command in the irb session?
@dEAN : use the command `next` instead of `step`
How would you post this data to a Rails controller using XML?
Is this format correct?
http://pastie.org/387041
Q: How do you get a Virtual Attribute to be listed when you use .to_json or .to_xml?
@Christoph Olszowka
I bet you're right! That makes sense.
I do have Ruby 1.9 installed but I can't seem to get any gems to work with it. I'm running Rails 2.3 just fine. But I had to run it with Thin and not webrick because each request was taking 40 seconds...but I digress... :-)
@RyanB
I had to add "include Authentication" in the application_controller after following your example. No biggie. I might have messed up but anyway, just FYI.
BTW, you rock dude!
~cbmeeks
I have the same problem as Patrick above. When you submit the form and the validations fails, none of the Credit Card fields get tagged with class="fieldWithErrors". Does anyone know how to get them to?
Markaby works great except for one minor problem:
I need to user a form_remote_for call inside of the markaby block. This doesn't work at all, and I have tried many different angles on it.
Is there anyway to get a form_remote_for block inside of a markaby block and have it output correctly, or is this entirely impossible?
Thanks for this episode Ryan. I have a question here. You talked about some methods in this episode that are provided by has_many: association ( for example- cart.line_items.build, line_item.build_delivery_method, etc.. )What do you mean by that? And is there any documentation for such methods?
I will appreciate your help to make me understand this.
How can I make rails generate ALL urls to point to a valid subdomain?
Example:
personal.blog.local has a page with a url:
<%= link_to "Show blog", blog_root %>
If I follow your howto, this will work, obviously, but now my question is: how can I generate urls to, let's say the "edit" action?
<%= link_to "Show blog", edit_blog_root %> doesn't work. Kind of logical, since we didn't define it anywhere, but I still want to know how this can be done dynamically.
So the thing I'm looking for, is some kind of directive in the routes config file, that generates all kinds of default paths I can use. Something like this:
map.resources :blogs, [insert specific information here so that rails generates edit/destroy/show/etc... URLs]
Is this possible anyway?
If anyone has troubles installing Rails 2.3.0 RC1, you may need to install Rack first:
sudo gem install rack
I like the new feature, thanks you!
in my utter despair and after hours trying and erring i turned to you and your readers with the above 70. egorbrandt Feb 11, 2009 at 06:24.
getting bold and bored i simply removed the <%= javascript_include_tag 'jquery', 'application' %> from application.html.erb. your guess is as good as was mine: it worked, and solved my original problem with the two posts (or puts).
why would removing that tag solve my problem? my confusion is even greater right now.
@cbmeeks: This is probably because Ruby < 1.9 does not keep insertion order on hashes:
irb(main):002:0> {:add => ".", :commit => "-m 'foo'"}
=> {:commit=>"-m 'foo'", :add=>"."}
Thus, the commit command will be executed first, even though you gave it as the "second" argument. I don't know about the inner workings of the git method in the Rails Templates, but probably it's just a plain "def git(options)", so the arguments you provide become a plain hash with mentioned problem.
@Ryan: I think there is an issue with using both git commit and rake gems:install, since the former will use your git credentials specified in your user config, while the latter will need sudo rights.
Executing the whole script as sudo will let gems install, but will probably give you empty git committer names (as long as you do not have them specified for root as well) and of course root permissions on all your apps files.
I found a nice detail in Peter Coopers example template (see http://gist.github.com/33337), which executes gems:install with the additional :sudo option:
rake('gems:install', :sudo => true)
Thanks for another great tutorial Ryan!
your screencasts are great.
as a starter - and slow student - i'm often intrigued to look for the underlying code (and relations) and have it working 'my way.'
maybe you, or one of your readers could help me with the following.
after adjusting and adding the 'screencast code' to my app, there are two reviews submitted to the database... and subsequently returned on the products/show.html.erb screen. any idea how i could solve this would be welcome!
for your thoughts: putting the alert('hello') in the create.js.erb file gives me this friendly message two times.
thanks again, egorbrandt
Using the following
http://pastie.org/385727
git :commit is executed before git :add.
Anyone know why? I'll try to break it into two lines but I just thought it was weird.
Hey All,
Someone, please help me on this urgently.
While running "rake test:acceptance" on console I am getting this error
***************
rake aborted!
uninitialized constant SeleniumOnRailsConfig::ERB
*******************
Could you please show me links for Selenium in Rails as Am using the beta for Rails 2.2
Am new to this.....
Please....
@Chess: deleting the object destroys the attachment as well as the folder structure. Only the public/<modelname> remains.
The id/style/style.extn gets deleted.
Curious about applying templates to existing apps, as I'll be doing it a lot. Will everything behave gracefully?
I am trying to use Paperclip with a form_remote_for (ajax form) .. but it seems to not recognize the associated form field as being related to the paperclip generated fields.
i.e. I am using <%= form.file_field :pdf %>
and when I submit, I get a message indicating the Pdf must be set - as if it isn't being sent. I can verify it is in the params in the log and that the form is using multipart=>true
Are there known issues or extra steps I must take to get Paperclip to work with a remote form (ajax)?
Thanks - great railscast and plugin!
@Andy, @Yitzhak interesting, it is downloading all the way for me. Try right-clicking the link and choosing download instead of having it load in the browser. You may also want to try the alternative format (for iPod).
@jeroen: One disadvantage of your solution is, that your "templates" do include one specific version of rails and included gems & plugins (Updating rails doesn't update all files in your app. E.g. the config/environment.rb or the config/initializers/* are only generated for new apps).
Also you can't use functions like ask or yes? nor can your "templates" inherit from other templates.