For the life of me I cannot get the many to many association to work. The roles for each user will not save, however if I update a user's account in the console the value will save. I'm using MySQL as my DB, could this be the issue?
Doesn't work for me. I can't create the scripts because of active record. How do I either turn off active record, or what do I put in databases.yml (currently it's blank) to make it stop wanting to connect to the db?
Hi, how to authorize acces to custom methods other than CRUD? By default all non standard methods are just blocked, how to deal with it?
has_permission_on :foos, :to => :ownmethod doesnt work :/
I expected to hear some use cases for such databases. I don't suppose they perform as good as *SQL, and I guess they're only supposed to be used in certain situations? I found this was missing from the railscast.
Otherwise nice railscast.
Hi, Ryan
I want to ask what problems may occur if when i need to do some long lasting job i create new Thread and let it handle all the work and i continue with my request. So basically:
but strange its not allowing me to login. and if I remove configuration from environment.rb its working
any idea ??
I want to use sessions with sessions table.
I saw this used with Rackamole (http://rackamole.com/) Maybe you can look into Rackamole too! It's a great rack plugin for monitoring a rails application.
I'm not used to this kind of DBM, I mostly use SQL (MySQL and MSSQL) so I can't really see the big avantages of this kind of DBM...
Do you know of any resources for creating controllers/views where users could edit their signup information? I tried creating my own but it seems that there is some code I am missing that was generated that redirects my edit form submission to the create controller method for users. I can't seem to get it to call my edit method, is there some code I should add to my routes.rb file?
Script to install MongoDB on OS X using Homebrew and set it to automatically run: http://gist.github.com/265272
One note about the screencast: Tasks should have been embedded in the Projects collections, because a single task isn't shared among projects. This is the true Mongo way. MongoMapper supports embedded models in a very nice object-oriented way.
Thanks a LOT for feeding us Awesome screencast! I can't wait for the next screencast that explains more advanced mongo mapper like callback, how to tackle many to many relation, and probably if there is any asynchronous way for mongodb using ruby.
Where is the clap of your finger?? I was expecting it !
I just wanted to mention that there was also a screencast series recently done on MongoDB by Joon You (rubyhead) which can be found on http://teachmetocode.com.
Ryan, what's reason for usage of "h" escape_html method within Rails 2.3.5?
By the way, MongoDB’s performance as compared to others
http://prajwal-tuladhar.net.np/2009/11/15/500/mongodbs-performance-as-compared-to-others-esp-couchdb/
I also would love to see a Railscast on google4r-checkout. It seems like a great plug-in and not nearly as klunky as working with PayPal. However, I still have a lot of questions after reading through the google4r-checkout documentation. I'm sure Ryan would answer most of them with his excellent Railscast presentations.
Hi Ryan...
I always watching your tutorial about RoR. But what I can't find is How to Build Chat Application using RoR (e.g. Juggernaut). Would you please to email me if you've considered to make chat tutorial.
Thanks...
Hello,
I get this error message every time i try upload am image.
NB: Foto is BD column name.
There were problems with the following fields:
* Foto /tmp/stream20091228-2242-xptimu-0 is not recognized by the 'identify' command.
* Foto /tmp/stream20091228-2242-xptimu-0 is not recognized by the 'identify' command.
Good to know about MongoDB. I have a question though. Where is the data stored in mongodb? Is there any way to perform full text search and db backups, etc like traditional relational databases would allow us to do?
Also how is it different from storing data in xml files?
Devise does work with Mongo, I've been playing with it this week.
What I would love is a railscast on gridfs. I'm fairly new to rails and I got Devise to work with mongo and mongomapper, but gridfs is confusing me no end.
@Levy, great points. Here I wanted to show what Rails developers are most familiar with to get started. I hope to make a more advanced episode in the future where I show some of the things that make MongoDB more unique (most were touched on in that blog post).
@Mantas, that's a great question. AFAIK Authlogic still does not support MongoMapper however there is an open ticket on it.
Very nice Ryan!
I only looked into MongoDB itself for a few but never tried to do anything with it in Rails. That MongoMapper Gem seems to work very well! I will definitely give it a shot!
It's worth noting that this example only shows a normal table to table relationship. In "mongoDBland" this is called a *db reference*, there is, a reference between 2 collections.
There's this simple relationship between tables (actually collections in mongoDB), and there's the new thing which is embedded documents. To embeded the Task model inside a Project, in this example, you have to change the file "app/models/task":
# models/task.rb
class Task
include MongoMapper::EmbeddedDocument
...
That's it.
And to those asking "Should I embeded or reference?", read more this subject at:
Yes, sorry. I meant that that "git add ." is only needed the first time for new files and the following times (for existing files) should "git commit -a" be enough...
Great screencast Ryan. Yet again, exactly what I was looking for. I have a question though; How would you go about caching something like this? I have just implemented this in a site which (I hope) will have quite high traffic, mainly db reads. I've used mongodb, so hopefully that will help.
ArgumentError in Searches#show
Showing app/views/searches/show.html.erb where line #1 raised:
wrong number of arguments (0 for 1)
Extracted source (around line #1):
1: <%= render :partial => @search.advertisements %>
any idea how to fix it??
yes i've got a partial _advertisements in app/views/advertisements
and it looks like that
http://pastie.org/757620
thx for any help
regards
Andrés Mejía: If you had watched the episode, you would have known that that would still require the database table to be present, even if you never call #save.
simon: like Ryan mentioned there are a few gems around but e.g. if you're not using tableless models a lot, the solution presented in the ep. is more simple and a gem is really unnecessary unless you're doing this kind of stuff often.
Great screencast. One small point / question for Ryan.
You are using a CART model for recording a line item selected for purchase. I am assuming you would have a CART -> LINE_ITEM type relationship.
You are then basically recording that "this cart has been purchased" with the relationship to the ORDER table.
Im curious if this is your preferred structure for an eCommerce app? Spree, for example, does not have a cart. Everything goes into an ORDER -> LINE_ITEM type relationship and then you eventually mark an order as "complete" when purchased.
Im really REALLY struggling with the best eCommerce structure and was hoping you could provide some direction towards what you've done.
@Matthew as long as you use Mongomapper in your models there shouldnt be any calls to ActiveRecord, and therefore no problems with configurations.
For the life of me I cannot get the many to many association to work. The roles for each user will not save, however if I update a user's account in the console the value will save. I'm using MySQL as my DB, could this be the issue?
Doesn't work for me. I can't create the scripts because of active record. How do I either turn off active record, or what do I put in databases.yml (currently it's blank) to make it stop wanting to connect to the db?
Hi, how to authorize acces to custom methods other than CRUD? By default all non standard methods are just blocked, how to deal with it?
has_permission_on :foos, :to => :ownmethod doesnt work :/
I expected to hear some use cases for such databases. I don't suppose they perform as good as *SQL, and I guess they're only supposed to be used in certain situations? I found this was missing from the railscast.
Otherwise nice railscast.
Instead of using:
order_path(@order, :format => 'pdf')
I prefer to create a helper method like this
def pdf(path)
path + '.pdf'
end
and then call on the view
pdf(order_path(@order))
this way the url will look like you are pointing to a stored file instead of a pdf generator.
Cheers
Good tutorial
Hi, Ryan
I want to ask what problems may occur if when i need to do some long lasting job i create new Thread and let it handle all the work and i continue with my request. So basically:
action start
Thread.new{long action}
action end
I want to use this plugin with sessions table with configuration in environment.rb
config.action_controller.session_store = :active_record_store
and
rake db:sessions:create
rake db:migrate
but strange its not allowing me to login. and if I remove configuration from environment.rb its working
any idea ??
I want to use sessions with sessions table.
Sorry please ignore my last comment, I was forgetting to change my form elements ( form_for @user ).
See http://railsforum.com/viewtopic.php?pid=115502#p115502
How's the performance of MongoDB? Especially when it comes to fulltext searching?
Hi Ryan!
I saw this used with Rackamole (http://rackamole.com/) Maybe you can look into Rackamole too! It's a great rack plugin for monitoring a rails application.
I'm not used to this kind of DBM, I mostly use SQL (MySQL and MSSQL) so I can't really see the big avantages of this kind of DBM...
Thanks.
Do you know of any resources for creating controllers/views where users could edit their signup information? I tried creating my own but it seems that there is some code I am missing that was generated that redirects my edit form submission to the create controller method for users. I can't seem to get it to call my edit method, is there some code I should add to my routes.rb file?
I already have
map.logout '/logout', :controller => 'sessions', :action => 'destroy'
map.login '/login', :controller => 'sessions', :action => 'new'
map.register '/register', :controller => 'users', :action => 'create'
map.signup '/signup', :controller => 'users', :action => 'new'
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
Script to install MongoDB on OS X using Homebrew and set it to automatically run: http://gist.github.com/265272
One note about the screencast: Tasks should have been embedded in the Projects collections, because a single task isn't shared among projects. This is the true Mongo way. MongoMapper supports embedded models in a very nice object-oriented way.
@Paul
There's also a faster, but not equally flexible way of doing it.
http://fukamachi.org/wp/2009/11/20/rails-metal-mongodb-gridfs-access/
Code needs editing on the parts of what database it uses.
@Paul
You need a Rack or Metal-library that can handle the serving on the view-side.
http://github.com/twoism/metal_grid_fs/
For example :)
Thanks a LOT for feeding us Awesome screencast! I can't wait for the next screencast that explains more advanced mongo mapper like callback, how to tackle many to many relation, and probably if there is any asynchronous way for mongodb using ruby.
Where is the clap of your finger?? I was expecting it !
Great screencast Ryan!
I just wanted to mention that there was also a screencast series recently done on MongoDB by Joon You (rubyhead) which can be found on http://teachmetocode.com.
Apologies for the shameless plug ;-)
Ryan, what's reason for usage of "h" escape_html method within Rails 2.3.5?
By the way, MongoDB’s performance as compared to others
http://prajwal-tuladhar.net.np/2009/11/15/500/mongodbs-performance-as-compared-to-others-esp-couchdb/
Thibaud and Fredrik, tried all those options.
I may just not know enough, but I couldn't get them to work. Saved the image to mongo, but couldn't pull it back out for love or money.
I also would love to see a Railscast on google4r-checkout. It seems like a great plug-in and not nearly as klunky as working with PayPal. However, I still have a lot of questions after reading through the google4r-checkout documentation. I'm sure Ryan would answer most of them with his excellent Railscast presentations.
How about performance (for example vs mysql)?
Hi Ryan...
I always watching your tutorial about RoR. But what I can't find is How to Build Chat Application using RoR (e.g. Juggernaut). Would you please to email me if you've considered to make chat tutorial.
Thanks...
Hello,
I get this error message every time i try upload am image.
NB: Foto is BD column name.
There were problems with the following fields:
* Foto /tmp/stream20091228-2242-xptimu-0 is not recognized by the 'identify' command.
* Foto /tmp/stream20091228-2242-xptimu-0 is not recognized by the 'identify' command.
Can you help me? thanks in advance
There's also http://github.com/twoism/grip for gridFs.
RailsTips got an article released a few days ago about it -> http://railstips.org/2009/12/23/getting-a-grip-on-gridfs
@paul gatt for mongodb and gridfs there is the new CarrierWave gem: http://github.com/jnicklas/carrierwave
Ryan great screencasts!
What are the advantages of using mongodb over couchdb?
Good to know about MongoDB. I have a question though. Where is the data stored in mongodb? Is there any way to perform full text search and db backups, etc like traditional relational databases would allow us to do?
Also how is it different from storing data in xml files?
Devise does work with Mongo, I've been playing with it this week.
What I would love is a railscast on gridfs. I'm fairly new to rails and I got Devise to work with mongo and mongomapper, but gridfs is confusing me no end.
@Levy, great points. Here I wanted to show what Rails developers are most familiar with to get started. I hope to make a more advanced episode in the future where I show some of the things that make MongoDB more unique (most were touched on in that blog post).
@Mantas, that's a great question. AFAIK Authlogic still does not support MongoMapper however there is an open ticket on it.
http://github.com/binarylogic/authlogic/issues#issue/15
There are many plugins I would like to see support MongoMapper. I encourage them to build in an adapter to deal with the different databases.
Just a quick note that there is a MongoDB hosting service called MongoHQ.
http://www.mongohq.com
@Mantas:
Devise should work with it. I'm not sure about Authlogic although.
Any ideas how to handle authentication with mongomapper? Does authlogic work with it?
Thank you, great cast as always.
Was hoping for a railscast to help me get started with MongoDB. Thanks! :)
Very nice Ryan!
I only looked into MongoDB itself for a few but never tried to do anything with it in Rails. That MongoMapper Gem seems to work very well! I will definitely give it a shot!
Thanks.
Great screencast, Ryan!
It's worth noting that this example only shows a normal table to table relationship. In "mongoDBland" this is called a *db reference*, there is, a reference between 2 collections.
There's this simple relationship between tables (actually collections in mongoDB), and there's the new thing which is embedded documents. To embeded the Task model inside a Project, in this example, you have to change the file "app/models/task":
# models/task.rb
class Task
include MongoMapper::EmbeddedDocument
...
That's it.
And to those asking "Should I embeded or reference?", read more this subject at:
http://www.mongodb.org/display/DOCS/Schema+Design#SchemaDesign-Embedvs.Reference
Cheers!
Levy
it's really useful
Thank you, Ryan!
T
Yes, sorry. I meant that that "git add ." is only needed the first time for new files and the following times (for existing files) should "git commit -a" be enough...
Great screencast Ryan. Yet again, exactly what I was looking for. I have a question though; How would you go about caching something like this? I have just implemented this in a site which (I hope) will have quite high traffic, mainly db reads. I've used mongodb, so hopefully that will help.
thanks for the tutorial. its great
i've got this kind of problem:
ArgumentError in Searches#show
Showing app/views/searches/show.html.erb where line #1 raised:
wrong number of arguments (0 for 1)
Extracted source (around line #1):
1: <%= render :partial => @search.advertisements %>
any idea how to fix it??
yes i've got a partial _advertisements in app/views/advertisements
and it looks like that
http://pastie.org/757620
thx for any help
regards
LOL @ Settlers of Catan... thats a fun game. You screencasts are invaluable!
<% form_for @product do |f| %>
<%= f.error_messages %>
<p>
<%= f.label :name %><br />
<%= f.text_field :name %>
</p>
<p><%= f.submit "Submit" %></p>
<% end %>
.. and now I get the error below
Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id
----------------
For people who are getting the aforementioned error message you are missing a = in the code.
<% form_for @product do |f| %>
should be
<%= form_for @product do |f| %>
and you should no longer get an error message!
It took me a good half an hour to figure this out
to: klumsyBird
http://github.com/freelancing-god/thinking-sphinx/blob/6ecbc568ff8851c36c81c1784bf7f866d4077ca0/lib/thinking_sphinx/auto_version.rb
Update your sphinx version to 0.9.8 or 0.9.9
Andrés Mejía: If you had watched the episode, you would have known that that would still require the database table to be present, even if you never call #save.
simon: like Ryan mentioned there are a few gems around but e.g. if you're not using tableless models a lot, the solution presented in the ep. is more simple and a gem is really unnecessary unless you're doing this kind of stuff often.
Great screencast. One small point / question for Ryan.
You are using a CART model for recording a line item selected for purchase. I am assuming you would have a CART -> LINE_ITEM type relationship.
You are then basically recording that "this cart has been purchased" with the relationship to the ORDER table.
Im curious if this is your preferred structure for an eCommerce app? Spree, for example, does not have a cart. Everything goes into an ORDER -> LINE_ITEM type relationship and then you eventually mark an order as "complete" when purchased.
Im really REALLY struggling with the best eCommerce structure and was hoping you could provide some direction towards what you've done.
So I am trying out your code exactly sans your credentials and I am getting the following error:
Error: There's an error with this transaction. Please enter a complete billing address.
How come it worked in your example?