Description: This APP is a small sample, where a User can blog
Run the Command
$ rails generate scaffold user name age:integer email
Run the command
$ rails generate scaffold article title content:text user:references
Change in config/routes.rb.
Un-comment line no. 8 and change it to:
# resources :articles
resources :users, shallow: true do
resources :articles
end
Change the routes in line 2,3 to
root 'users#index'
$ rake db:migrate
Add the below line to file "app/models/user.rb" before end
has_many :articles
$ bundle exec erd
$ sudo apt-get install graphviz
$ rake diagram:all
Note: Check the file "erd.pdf" and folder "doc"
$ rails server
ERROR
</br>
</br>
</br>
<%= link_to @user.name + ' articles', user_articles_path(@user) %>
</br>
</br>
</br>
ERROR
<%= link_to 'New Article', new_user_article_path %>
ERROR
@user = User.find(params[:user_id])
@article = @user.articles.new
ERROR
<%= form_for([@user, @article]) do |f| %>
Functionality: User ID is visible, lets hide it
<div class="field" style="display:none">
ERROR
<%= link_to 'Back', user_articles_path %>
articles" at line 28 to ERROR
@user = User.find(params[:user_id])
@article = @user.articles.new(article_params)
ERROR "app/views/articles/edit.html.erb" at line 6 to
<%= link_to 'Back', user_articles_path(user_id: @article.user.id) %>
Functionality: Link in Article List which redirects to User List
<%= link_to "All Users", users_path %>
$ bundle install --without production
$ git add .
$ git commit -a -m "Update Gemfile.lock for Heroku"
$ heroku create
$ git push heroku master
$ heroku run rake db:migrate
$ heroku apps:rename paxcel-session-app