You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
correction-tp-rails/README.md

43 lines
1.1 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# README
Commandes lancées :
Question 2.2 :
* `rails server`
Question 2.3 :
* `rails generate controller HomeController`
Question 3 :
* `rails generate model Creature name:string health_points:integer`
* La migration n'est pas lancée sur la base
* `rails db:migrate`
Question 3.1 :
Je teste la creature dans une console rails que je lance avec `rails console` :
```ruby
rails console
Loading development environment (Rails 7.0.4.3)
irb(main):001:0> c = Creature.create(name: "Thrall", health_points: 489)
TRANSACTION (0.1ms) begin transaction
Creature Create (0.4ms) INSERT INTO "creatures" ("name", "health_points", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["name", "Thrall"], ["health_points", 489], ["created_at", "2023-03-26 13:19:57.492017"], ["updated_at", "2023-03-26 13:19:57.492017"]]
TRANSACTION (0.9ms) commit transaction
=>
#<Creature:0x00000001070374f8
...
irb(main):002:0> c.to_label
=> "Thrall (489)"
```
Question 3.2 :
* `bundle add random_name_generator` pour ajouter la gemme au gemfile, effectuer la résolution de dépendance et installer la nouvelle gemme
* `rails db:seed`