I added stylebar support to cRazzed, using RJS, cookies, and Sass.
So far there’s “wacky”, “aqua”, and “hot pink”.
Maybe I’ll be able to add a live demo… although it’s quite insecure… maybe I’ll just post the sources.
I added stylebar support to cRazzed, using RJS, cookies, and Sass.
So far there’s “wacky”, “aqua”, and “hot pink”.
Maybe I’ll be able to add a live demo… although it’s quite insecure… maybe I’ll just post the sources.
Okay, so, it’s much easier if you have RubyGems installed, and if you do:
[sudo] gem install -y rails
rails [--database=sqlite3] [options] [projectname]
You could read the README, but that’s complicated and this is a lot easier.
First of all, “cd” into your new project.
cd [projectname]
Then, you can start with a Model.
In Rails, Models are like collections of objects. Behind them is a technology called ActiveRecord. Using this, we can…
And other thing-a-ma-bobs.
IMPORTANT! Make sure you edit the db/migrate/[number]_create_[modelname].rb file first so that where it says create_table(…) there is a line like this right under it.
t.column :id, :integer, :null => false
Strangely, the generator doesn’t automatically put this in… I’ll have to file a bug report…
Well, there is something called scaffolding which you could put in your app/controllers/[controllername]_controller.rb file… But I’m gonna teach you the hard , kind-of easy way.
First, the same way we generate a model:
script/generate controller [controllername]
# ...or...
script/generate scaffold [controllerandmodelname]
The app/controllers/[controllername]_controller.rb file should look like this
class [CamelCaseControllerName] < ApplicationController
layout "[layoutname]"
def [viewmethod]
[helping-hands]
end
#...
end
I actually prefer using Haml rather than the usual RHTML, so go ahead and use RubyGems:
[sudo] gem install -y haml
#and
cd ..
haml --rails [projectname]
cd [projectname]
Great, your project is now Haml-enabled. What do I do now?
Fire up app/views/layouts/[layoutname].haml, and put in
!!!
%html
%head
%title= @title
%body
= yield
And, so, a beginning.
You may now delete everything in the public/ folder except the folders images/, stylesheets/, and javascripts/. After that:
script/server
Then fire up Firefox and go to:
http://localhost:3000/[controllername]/
Something should show if you configured everything correctly.