Don't use "disable with text" option with your jquery ajax binding
I ve just spent 5 hours to understand what was going wrong with my ajaxy form. I use jquery on rails and ajaxForm plugin, I have some form already working good and tried to a new one.
But this time it doesnt work, I dont understand why my form send twice the request, first with ajax header and second time with html request. I even tried to write raw javascrit, livequery and so on. Nothing make it works. Finally I want to check a little thing I add on the form: ‘disable with text’ option. I disabled it and miracle it works now.
I ve lost 5 hour of my time for this little cosmetic tool that s mess up ajax binding.
Then my advice: DON’T USE “DISABLE WITH TEXT” OPTION WITH YOUR JQUERY AJAX BINDING.
Rails Ajax rating system (Part 1)
Needed for a little project, I found a plugin: “acts_as_rated”.
“Adds rating capabilities to any ActiveRecord object.
It has the ability to work with objects that have or don’t special fields to keep a tally of the
ratings and number of votes for each object.
In addition it will by default use the User model as the rater object and keep the ratings per-user.
It can be configured to use another class, or not use a rater at all, just keeping a global rating”
Not yet released as gem please checkout the following trunk :
svn://rubyforge.org/var/svn/acts-as-rated/trunk/acts_as_rated
Installation:
script/plugin install svn://rubyforge.org/var/svn/acts-as-rated/trunk/acts_as_rated
Generate the Rating model:
The rater is User (by default) and rated object is Photo
script/generate migration add_rating
class AddRating < ActiveRecord::Migration
def self.up ActiveRecord::Base.create_ratings_table Photo.add_ratings_columns end def self.down- Remove the added columns
Photo.remove_ratings_columns
ActiveRecord::Base.drop_ratings_table
end
rake db:migrate
Add table ratings and columns rating_count, rating_total, rating_avg to the Photos table.
Usage:
class Photo < ActiveRecord::Base
acts_as_rated :rating_range => 0..5
end
stephane = User.find_by_username(“stephane”)
picture = Photo.new(“beautiful picture”)
picture.rate 4, stephane
that’s all for now …
(Next: integrate CSS rating interface)
Admin interface for Ruby on Rails
When choosing to develop with RoR instead of django, only one thing was missing : an admin interface. In django when you generate a project you have a small interface to manage your data. In Ruby on Rails you can use the magic scaffold but it’s not very convenient.
The first initiative I have discovered was ajax scaffold generator, an advanced scaffold with some ajax stuff and a real way to integrate an admin interface, but you still have to do it.
Then I found two other projects:
- auto-admin generating a django like interface
- streamlined a more completed generator
I let you play with these three different projects, for different using.