Coder Social home page Coder Social logo

hogwartz's Introduction

Hogwarts!

This repo includes seedfiles, creating an entity-relationship-diagram, using form_for and form_tag with drop downs and checkboxes referencing other models.

Takes aways

Seeds

You can prepopulate your database by adding code to your seeds.rb file. Just run $ rake db:seed

If you want to seed your database on heroku run $ heroku run rake db:seed

Relationships

$ rake erd will generate a PDF in your app directory of your models relationships.

Be sure to run $ brew install graphviz first.

forms and params

Creating a form by hand will result in a params like the following:

params = {name: "Harry Potter", age: 12, id: 1, action: 'create', controller: 'students'}

And in your controller

Student.new(name: params[:name], age: params[:age])

form_for can render an HTML form for a specific model. This means your params will contain a hash representing that object.

params = {student: { name: "Harry Potter", age: 12 }, id: 1, action: 'create', controller: 'students'}

And in your controller

Student.new(params[:student])

You can pass the entire student hash in to create a new object in your controller

forms with belongs_to and habtm

Check out the new student form for a select box drop down of houses. Check out the edit student page for check boxes of all the students spells.

hogwartz's People

Contributors

phlco avatar xinecoulter avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.