DEV Community ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป

koki-takishita
koki-takishita

Posted on

rails generators ๅˆถ้™่จญๅฎš

rails g ใ‚ณใƒžใƒณใƒ‰ใง็”Ÿๆˆใ•ใ‚Œใ‚‹ใƒ•ใ‚กใ‚คใƒซใ‚’ๅˆถ้™ใ™ใ‚‹

config/application.rbๅ†…ใซไธ‹่จ˜ใฎใ‚ˆใ†ใซ่จญๅฎšใ™ใ‚‹

config.generators do |g|
  g.jbuilder       false
end
โ‘  # p config.generators
Enter fullscreen mode Exit fullscreen mode
  • ๅ„็จฎ่จญๅฎš้ …็›ฎใฏใƒ‰ใ‚ญใƒฅใƒกใƒณใƒˆๅ†…ใง็ขบ่ชใงใใŸ Rails::Generators Image from Gyazo
  • ใ‚ณใƒผใƒ‰โ‘ ใ‚’ๆœ‰ๅŠนๅŒ–ใ—ใฆใ€ใ‚ตใƒผใƒใƒญใ‚ฐใ‚’็ขบ่ชใ™ใ‚‹ใจไธ‹่จ˜ใฎใ‚ˆใ†ใซ่จญๅฎš้ …็›ฎใ‚’็ขบ่ชใงใใ‚‹ Image from Gyazo

ใƒ‰ใ‚ญใƒฅใƒกใƒณใƒˆใซ่จ˜่ฟฐใ•ใ‚Œใฆใ„ใชใ„้ …็›ฎ...

ใ‚ใ‹ใ‚‰ใชใ‹ใฃใŸใ“ใจ
  • ใƒซใƒผใƒ†ใ‚ฃใƒณใ‚ฐ็”Ÿๆˆใฎๆœ‰็„กใฎ่จญๅฎš้ …็›ฎใงใ‚ใ‚‹skip_routesใฏใ€railsใ‚ฌใ‚คใƒ‰ใ€APIใƒ‰ใ‚ญใƒฅใƒกใƒณใƒˆใ€ใใฎไป–ใฎๅ…ฌๅผใจๆ€ใ‚ใ‚Œใ‚‹ใƒชใ‚ฝใƒผใ‚นใ‚’่ชฟในใŸใŒ่ฆ‹ใคใ‹ใ‚‰ใšๅ€‹ไบบใƒ–ใƒญใ‚ฐใชใฉใฎ2ๆฌกใ€3ๆฌกใชใฉใฎใƒชใ‚ฝใƒผใ‚นใงใ—ใ‹็Ÿฅใ‚‹ใ“ใจใŒใงใใชใ‹ใฃใŸใ€‚
ๅˆ†ใ‹ใฃใŸใ“ใจ

railsใฎใƒชใƒใ‚ธใƒˆใƒชใซใฆใ€Rails::ControllerGenerator::ControllerGeneratorใ‚ชใƒ–ใ‚ธใ‚งใ‚ฏใƒˆclass_optionใฎๅผ•ๆ•ฐใซskip_routesใŒ่จ˜่ฟฐใ•ใ‚Œใฆใ„ใ‚‹ใ“ใจใ‚’็ขบ่ชใงใใŸใ€‚ไธŠ่จ˜ใฎใ‚ณใƒผใƒ‰ใจใฉใฎใ‚ˆใ†ใซ็ตกใ‚“ใงใใ‚‹ใ‹ใฏใ‚ใ‹ใฃใฆใ„ใชใ„ใŒใ€skip_routes true or falseใ‚’่จ˜่ฟฐใ™ใ‚‹ใ“ใจใงใ€rails g controllerๅฎŸ่กŒใฎ้š›ใซ่จญๅฎšใ‚’่ชญใฟ่พผใฟใ€config.generators.skip_routes falseใชใ‚‰ใฐใ€ใƒซใƒผใƒ†ใ‚ฃใƒณใ‚ฐ็”Ÿๆˆใ‚’็„กๅŠนใซใ™ใ‚‹ใจใ„ใ†ๅ‹•ใใ‚’ใ™ใ‚‹ใจๆ€ใ‚ใ‚Œใ‚‹ใ€‚

ๆ„Ÿๆƒณ

APIใƒ‰ใ‚ญใƒฅใƒกใƒณใƒˆใชใฉใฎๅ…ฌๅผใƒชใ‚ฝใƒผใ‚นใ‹ใ‚‰ๆƒ…ๅ ฑใ‚’่ชญใฟๅ–ใฃใฆใ„ใ‚‹ใŒใ€ใ‚‚ใ—ๅ…ฌๅผใƒชใ‚ฝใƒผใ‚นใซๆƒ…ๅ ฑใŒใชใ„ใ€ใ‚‚ใ—ใใฏ่ฆ‹ใคใ‘ใ‚‰ใ‚Œใชใ„ๆ™‚ใฎ่ชฟในๆ–นใซ่ชฒ้กŒใ‚’ๆ„Ÿใ˜ใŸใ€‚

Top comments (0)

We need YOUR help!

Want to contribute to Forem and learn about API documentation and testing at the same time? Pick up an issue to help us finish documenting our V1 API!