You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
26. Getting started with EverNote Web App Replica 27. Adding Notes and Installing Gems 28. Display Notes and Basic Navigation 29. Edit and Delete Notes 30. User and Notes Association (making notes private) 31. Modifications to User and Notes 32. Styling and Structure (import custom styling) 33. Adding Styling to Notes and Final Corrections 34. Yes... You made it.
Associate the Notes with the User app/models/note.rb
classNote < ActiveRecord::Basebelongs_to:userend
Associate the User with the Notes app/models/user.rb
classUser < ActiveRecord::Base# Include default devise modules. Others available are:# :confirmable, :lockable, :timeoutable and :omniauthabledevise:database_authenticatable,:registerable,:recoverable,:rememberable,:trackable,:validatablehas_many:notesend
In app/controllers/notes_controller.rb replace Note.new with current_user.notes.build to associate the note with the user and the user _id as per Devise
Update the index method in app/controllers/notes_controller.rb to only show the notes by the current user
def index
@notes = Note.where(user_id: current_user)
end
Re-adjust the routes config/routes.rb so if you are signed in you can go right to your notes
Rails.application.routes.draw do
devise_for :users
get 'welcome/index'
resources :notes
authenticated :user do
root 'notes#index', as: "authenticated_root"
end
root 'welcome#index'
end
32. Styling and Structure (import custom styling)
Renameapp/assets/stylesheets/application.css to app/assets/stylesheets/application.css/scss
require self includes the styling on this page require tree . includes the other style sheets
Hi Jen -
I apologize for the late notice, but I won't be able to make it tonight's
meet-up. Hope you have fun on your trip next week!
Andrea
Hi Andrea,
Thanks for letting me know feel free to email next time at [email protected] I don't have your email. Juan Luna will be there next week to help everyone. :)
Create Pinterest App
The repository of the code
26. Getting started with EverNote Web App Replica
27. Adding Notes and Installing Gems
28. Display Notes and Basic Navigation
29. Edit and Delete Notes
30. User and Notes Association (making notes private)
31. Modifications to User and Notes
32. Styling and Structure (import custom styling)
33. Adding Styling to Notes and Final Corrections
34. Yes... You made it.
26. Getting started with EverNote Web App Replica
$ rails new ever_note_clone
$ cd ever_note_clone
$ rails g controller Welcome index
config/routes.rb
Update the your Gemfile with the gems we will be using and so you can push to Heroku, then bundle again to install all the new gems
gem 'devise', '~> 3.5.2'
$ bundle
Rename
app/views/welcome/index.html.erb
toapp/views/welcome/index.html.haml
and update the html to haml%h1 NeverNotes
27. Adding Notes and Installing Gems
$ rails g model Note title:string content:text
$ rake db:migrate
Install simple_form
rails generate simple_form:install --bootstrap
Inside your views, use the 'simple_form_for' with one of the Bootstrap form
classes, '.form-horizontal' or '.form-inline', as the following:
`$ rails g controller Notes
Create the CRUD actions in the Note controller
app/controllers/notes_controller.rb
Update the routes
config/routes.rb
to add the CRUD actions28. Display Notes and Basic Navigation
Update the Note controller create action
app/controllers/notes_controller.rb
Create a view for the notes
app/views/notes/show.html.haml
Update the Note controller private method
find_note
app/controllers/notes_controller.rb
The (params[:id]) refers to the url parameter and the note id which here is 1 >> localhost:3000/notes/1
app/controllers/notes_controller.rb
Add a Link to show the note created in
app/views/notes/show.html.haml
Update the index action in the `app/controllers/notes_controller.rb to show all the notes in descending order
Add a Link to show all the notes in
app/views/notes/index.html.haml
29. Edit and Delete Notes
Update the Note controller update and destroy method in
app/controllers/notes_controller.rb
Add a Link to show the note created in
app/views/notes/show.html.haml
Create the Edit page
app/views/notes/edit.html.haml
Add a Link to create a new note in
app/views/notes/index.html.haml
30. User and Notes Association (making notes private)
Setting up Devise
In your terminal run:
$ rails g devise:install
Go to
config/environments/development.rb
and add this line to the botton of the file before the final end statementAdd this to
app/views/layouts/application.html.erb
In your terminal run:
$ rails g devise:views
In your terminal run:
$ rails g devise User
In your terminal run:
$ rake db:migrate
In your terminal run:
$ rails g migration add_user_id_to_notes
which creates:
db/migrate/20150916214610_add_user_id_to_notes.rb
Associate the Notes with the User
app/models/note.rb
Associate the User with the Notes
app/models/user.rb
In
app/controllers/notes_controller.rb
replace Note.new withcurrent_user.notes.build
to associate the note with the user and the user _id as per Devise31. Modifications to User and Notes
Update the index method in
app/controllers/notes_controller.rb
to only show the notes by the current userRe-adjust the routes
config/routes.rb
so if you are signed in you can go right to your notes32. Styling and Structure (import custom styling)
Rename
app/assets/stylesheets/application.css
toapp/assets/stylesheets/application.css/scss
require self
includes the styling on this pagerequire tree .
includes the other style sheetsCreate
app/assets/stylesheets/normalize.css
and copy every thing from the link below into ithttps://github.com/CrashLearner/EvernoteClone/blob/master/app/assets/stylesheets/normalize.css
Create
app/assets/stylesheets/normalize.css
and copy every thing from the link below into ithttps://github.com/CrashLearner/EvernoteClone/blob/master/app/assets/stylesheets/global.css.scss
Change
app/assets/stylesheets/notes.scss
toapp/assets/stylesheets/notes.css.scss
and copy every thing from the link below into ithttps://github.com/CrashLearner/EvernoteClone/blob/master/app/assets/stylesheets/notes.css.scss
Change
app/assets/stylesheets/welcome.scss
toapp/assets/stylesheets/welcome.css.scss
and copy every thing from the link below into ithttps://github.com/CrashLearner/EvernoteClone/blob/master/app/assets/stylesheets/welcome.css.scss
Change
app/views/layouts/application.html.erb
toapp/views/layouts/application.html.haml
and update it to haml syntaxGo to
app/views/welcome/index.html.haml
and add something similar to this:https://github.com/CrashLearner/EvernoteClone/blob/master/app/views/welcome/index.html.haml
33. Adding Styling to Notes and Final Corrections
Add
34. Yes... You made it.
Add
35. Let's make it better...
The text was updated successfully, but these errors were encountered: