How to ban bad ips in a rails app
The same is applicable for a Merb app, but there might be a better way to do it. Just put the following your application controller.
codes a lot
If the code is inexplicably missing from some of my posts it is because gist.github.com is down at the moment. Check back a little later.
The same is applicable for a Merb app, but there might be a better way to do it. Just put the following your application controller.
This is taken from Clayton Lengel-Zigich. Thanks.
Then run: sudo rake gems:install & sudo rake gems:unpack
1. Download JW FLV MEDIA PLAYER (mediaplayer.zip download link)
2. Copy and paste the player.swf file at public/flash/player.swf
3. Copy and paste the swfobject.js at public/javascript/swfobject.js
4. Configure your application.html.erb file to call swfobject.js in the head
That’s it, you should now be able to upload flv video files and view them in a flash player by going to http://localhost:3000/videos. For instructions on converting quicktimes videos to flash videos on file upload take a look at Jim Neath’s tutorial on converting videos with rails.
It’s a good idea to create a bucket for development and a bucket for production. If you decide to, you can do the following.
Note:this assumes you started your app with bort, and already have a settings.yml that gets loaded by the load_config.rb file using APP_CONFIG = YAML.load_file(”#{RAILS_ROOT}/config/settings.yml”)[RAILS_ENV].symbolize_keys)
In config/settings.yml
In video.rb
This pretty much comes about because of RailsTips and Peepcode. Thank you guys.
You want your user to be able to send an email and have that email get posted as a comment to the rails app.
1. Your rails app should already have the ability to send out emails
2. Your Rails app must already be capified via Capistrano or similar with some type of deployment recipe
3. You need an additional gmail or google apps account with imap enabled
4. You need the ability to run cron jobs on your server
First, setup the cron task and make it easy to run with cap deploy:start and cap deploy:stop
Create file lib/tasks/chores.rake
Create file config/cron.erb
Add the following near the end of your deploy.rb file
Second, setup the login information for the gmail mail account we will use to receive emails through.
Create file config/mail.yml and configure for imap
Install lockfile and tmail cause your gonna need them:
sudo gem install lockfile
sudo gem install tmail
Edit environment.rb
Edit lib/tasks/chores.rake and put the following code inside the each_minute task. (credit for this goes to John of RailsTips.org though I added a quick fix to handle multipart emails)
Deploy your app as usual with cap deploy
Next, run cap cron:start to start up the cron task. This will run every minute.
Send an email to the account you specified in mail.rb and after one minute you should see the email saved as a comment on the app.
The go to from railscasts but a little out of date since Rails 2.1 implemented timezones

script/plugin install git://github.com/aaronchi/jrails.git script/plugin install git://github.com/rakuto/jrails_in_place_editing.git
1 2 3 | <head> <%= javascript_include_tag :defaults %> </head> |
Restart your server
1. ..Controller
1 2 3 4 | class ProjectsController < ApplicationController in_place_edit_for :project, :acreage ... end |
2. ..View
1 | <%= in_place_editor_field :project, :acreage %> |
That’s it. For more on customization and additional options check out the jrails_in_place_editing readme at: