diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..599c1a0 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,5 @@ +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +insert_final_newline = true diff --git a/app/assets/javascripts/books.coffee b/app/assets/javascripts/books.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/books.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/stylesheets/books.scss b/app/assets/stylesheets/books.scss new file mode 100644 index 0000000..9fab565 --- /dev/null +++ b/app/assets/stylesheets/books.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Books controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/books_controller.rb b/app/controllers/books_controller.rb new file mode 100644 index 0000000..e2e8383 --- /dev/null +++ b/app/controllers/books_controller.rb @@ -0,0 +1,21 @@ +class BooksController < ApplicationController + def index + @books = Book.all + end + def new + @book = Book.new + end + def create + @book = Book.new(book_params) + if @book.save + redirect_to books_path, + notice: "Book was created successfully" + else + render :new + end + end +private + def book_params + params.require(:book).permit :title, :connet, :author + end +end \ No newline at end of file diff --git a/app/helpers/books_helper.rb b/app/helpers/books_helper.rb new file mode 100644 index 0000000..4b9311e --- /dev/null +++ b/app/helpers/books_helper.rb @@ -0,0 +1,2 @@ +module BooksHelper +end diff --git a/app/models/book.rb b/app/models/book.rb new file mode 100644 index 0000000..03d56b4 --- /dev/null +++ b/app/models/book.rb @@ -0,0 +1,2 @@ +class Book < ApplicationRecord +end diff --git a/app/views/books/_form.html.erb b/app/views/books/_form.html.erb new file mode 100644 index 0000000..acb758c --- /dev/null +++ b/app/views/books/_form.html.erb @@ -0,0 +1,9 @@ +<%= form_for book do |form| %> +