Standardising flash usage

Posted by stoyan Tue, 08 Nov 2005 23:50:00 GMT

Interesting discussion in the Rails ML about better (more standard) flash messages.

In general:
// :notice for positive feedback (action successful, etc)
// :message for neutral feedback (reminders, etc)
// :warning for negative feedback (action unsuccessful, error encountered, etc)

// FLASH_NAMES = [:notice, :warning, :message]

<% for name in FLASH_NAMES %>
  <% if flash[name] %>
    <%= "<div id=\"#{name}\">#{flash[name]}</div>" %>
  <% end %>
<% end %>
Francois Beausoleil already made a Flash Helper Plugin .

Posted in Programing, Ruby | no comments

Database-agnostic schemas

Posted by stoyan Tue, 08 Nov 2005 23:45:00 GMT

Ruby-based representation of your database schema. you can change from one database to another with no effort.

The schema generator is sort of the flip side of the new schema code in Rails 1.0. It takes a set of Rails migrations, aggregates them all together, and spits out a SQL file that describes the DB that you?「どィび「d get if you ran all of the migrations.

  • install schema generator gem
    gem install schema_generator
      
  • create migrate/ directory with your SQL schema. (example initial setup from Typo)
    cd myapp
    mkdir db/migrate/
    vim db/migrate/0_initial_schema.rb
    # or download example schema
    # wget -O migrations/0_initial_schema.rb \
    # "http://typo.leetsoft.com/trac/file/trunk/db/migrate/0_initial_schema.rb?rev=598&format=txt" 
    ./script/generate schema
      

This will create db/schema.mysql.sql , db/schema.postgresql.sql and db/schema.sqlite.sql

Posted in Ruby, Programing | no comments

Liquid templates

Posted by stoyan Mon, 07 Nov 2005 10:53:00 GMT

Liquid is a template engine optimized for xhtml and emails.

To start using liquid just extract it into vendor/plugins or better yet use the ./script/plugin script to install liquid. You can now start using templates with the .liquid file type…

Liquid features a very clean syntax and speedy execution speeds. The main difference to traditional ERb is that it does not rely on eval. This means that no potentially harmful code is executed when a Liquid template is compiled or rendered. The chief advantage is that you can let your users change templates without having to worry about your data?「どィび「s security.

Posted in Programing, Ruby | no comments

Plugins and Engines

Posted by stoyan Fri, 04 Nov 2005 10:59:00 GMT

The new way to make your code modular

1. Install redhanded?「どィび「s plugin manager (NOTE: script/plugin is now in the beta gems and will be part of the next release.)

$ rails myapp
$ cd myapp
$ curl http://lesscode.org/svn/rtomayko/rails/scripts/plugin > script/plugin
$ chmod +x script/plugin

2. script/plugin discover for the list of plugins repocitories (parsing RoR Wiki Plugins Page)

3. script/plugin list for the list of available plugins

4. Install Rails Engines
$ script/plugin install -x engines
$ script/plugin install -x login_engine
(Note: use -x if your application is still not under subversion control. Without -x, plugins manager will try to use svn:externals and will fail – Cannot install using externals because this project is not under subversion.)

Posted in Programing, Ruby | no comments

Test post from MarsEdit

Posted by stoyan Mon, 31 Oct 2005 21:46:11 GMT

Acording to Typo Desktop Clients’ page, MarsEdit can be used for posting to Typo. This is just a simple post to test this. Using MovableType API.

Posted in General, Programing, Ruby | no comments

YoDance

Posted by stoyan Fri, 28 Oct 2005 08:36:00 GMT

Yoda dancing hip-hop – small joke from the latest StarWars DVD

Posted in Fun

Themes

Posted by stoyan Thu, 27 Oct 2005 08:16:00 GMT

Added themes to my application, using theme generator .
wget http://darthapo.com/repos/theme_generator-1.0.2.gem
gem install theme_generator-1.0.2.gem
cd myapp
./script/generate theme default
Include at the bottom of myapp/config/environment.rb :
require_dependency 'theme_engine'
In the controllers:
class MyController << ApplicationController
  layout :themed_layout

  def current_theme
    'default'
  end
end

To set the theme for the entire application, use myapp/controllers/application.rb

In the views:
<img src=\"<%= theme_image_path 'my-image.png' %>\" />

Have also theme_stylesheet_path, theme_javascript_path etc. helper methods.

Posted in Programing, Ruby | no comments

Dragostea Din Tei Improved

Posted by stoyan Wed, 26 Oct 2005 13:52:00 GMT

Before sometime I had also a link to “New Eminem” clip, but for bad luck I lost it :(

Posted in Fun | no comments

Started using SwitchTower

Posted by stoyan Wed, 26 Oct 2005 13:45:00 GMT

Started using SwitchTower . Here a small task to check the Rails version on the servers (/railsapp/config/deploy.rb):
desc "Rails version" 
task :rails_version do
  run "gem list | grep '^rails'" do |channel, stream, out|
    puts "Host: #{channel[:host]}" 
    puts out
  end
end
Use it with:
rake remote_exec ACTION=rails_version

Posted in Programing, Ruby | no comments

Switch to Typo

Posted by stoyan Wed, 19 Oct 2005 08:47:00 GMT

Yesterday a switched my blog to Typo. Still running on high port until I figure how to use DAV and iCal features with lighttpd. During the installation I found a very good page with pointers to Ruby related blogs – TypoPowered . In general the page is about Typo-powered sites, but who are using Typo? Right, the people interested from Ruby and RoR ;) So lot of useful information on Typo-powered blogs.

Other good pointers:

Also before 1-2 days a decided to try Hatena – Japanese social online service – diaries, bookmarks etc. So I started ZHlog weblog there. But now I’m confused – which blog to use for what?

Posted in Personal, Ruby | no comments

Older posts: 1 ... 9 10 11 12 13

Powered
Ruby Blogs Directory
Performa
Box.net Refer