Amazon AWS SDK Uživatelský manuál Strana 10

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 26
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 9
test:
<<: *development
production:
<<: *development
6. Create app/models/my_record.rb as follows:
class MyRecord < AWS::Record::Base
string_attr :name
end
7. Create the SimpleDB domain:
$ rails console
> MyRecord.create_domain
8. Now, you can play around with the model by creating some records and querying them:
> MyRecord.find(:all).to_a
=> []
> MyRecord.new(:name => "The first one").save
=> true
> MyRecord.new(:name => "The second one").save
=> true
> MyRecord.where('name like ?', "%first%").count
=> 1
Exit the rails console before continuing to the next step:
> exit
To generate a scaffold controller for your model
Type the following command:
1.
$ rails generate scaffold_controller MyRecord name:string
$ rails server
2. Add a route to your scaffold controller in config/routes.rb:
Myapp::Application.routes.draw do
# add this line:
resources :my_records
end
Now, you can create records in the browser at localhost:3000/my_records. Note that this link is valid
only if you have completed the above procedure.
Version v1.0.0
7
AWS SDK for Ruby Developer Guide
Install and Run the Samples Included in the SDK
Zobrazit stránku 9
1 2 ... 5 6 7 8 9 10 11 12 13 14 15 ... 25 26

Komentáře k této Příručce

Žádné komentáře