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

1.1 KiB

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 :

 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