I took on this project to learn Ruby by example on the weekends/free time. I doubt this will be of use to anyone.
- Run rails new .
- Go into directory and run
bundle install
. - Make a Database using the
rails g migration initial_schema
. - Add Schema tables (create_table).
- Run
rake db:migrate
to autogenerate a Schema. - Make models and assign them corresponding to their relations.
- Make controllers and set up routes using the
config/routes.rb
file. - Add the root index file and corresponding stylesheets.
- Make views and define them in the controller. Add them to the
routes.rb
file and tag them into links into the rootindex.html.erb
file. - Define categories and subcategories in a way that would look good into a URL (breadcrumb).
- Define data for
config/seeds.rb
file and runrake db:seed
to make sure that duplicate data is not being stored and the CRUD operations are running in the Database. - Use
rails c
on the terminal and type<Record Name>.all
to see the record data. - Repeat this step for all the categories.
- Use the Controller to fetch the data from the database and use that fetched data to change the view of the page.
- Showed the listings of the different categories with ids by inserting a
category_path
, making a show function in theCategoriesController
and made a basicshow.html.erb
. - Showed the listings of different subcategories within categories with ids by inserting a
category_subcategory_path
, making a show function in theSubcategoriesController
and made a basicshow.html.erb
. - For the listings, we need the CRUD operations. So, add
resources :listings
toroutes.rb
file and then runrake routes
. - To use the listings CRUD operations, add a link to
index.html.erb
, then define the new function in theListingsController
and finally, add the template fornew.html.erb
. - Made a Listings view page and added a form to Create Listings. A new instance of the Listing was initiated in the
ListingsController
. - To submit the form, there is a need of a
create
action in theListingsController
. - Another private method called
listing_params
was made to make sure that only the specific data is passed through the parameters. - We add code to save the form data and reditrect the users to the listing after clicking submit.
- Added code to the ListingsController to show the listings page on form submit and added a file for the view. As we submit the form, sqlite3 database also got updated.
- Ran
rails g migration add_category_subcategory_to_listings
so that it is possible to have fields for categories and subcategories increate_listing
form. - Added code to
change
function and ranrake db:migrate
. - Added
find_by_category
method to select subcategories based on the category chosen and added a post request toroutes.rb
file. - There is no use for loading JS every time so
//=require_tree.
was removed fromapplication.js
file. - Added code to include js in the view, used
initializers
toprecompile js
file to select subcategories based on the category chosen and fixed bugs inroutes.rb
andSubcategoriesController
. - Added code to parse listing data according to categories and subcategories to show the listings accordingly for categories links.
- Added views for pages when there is no listing data for a particular Category or Subcategory.
- Added
geocoder
gem for search functionality for the listings and added code tolistings.rb
to join the details of the location. - Ran
rails g migration add_lat_long_to_listings
and added code to change function for the type of latitude and longitude. After that, ranrake db:migrate
. - Added code to
ListingsController
,Listings model
andindex.html.erb
to support search functionality for all the listings using the data present. - Added
devise
gem for Authentication functionality. Ranrails generate devise:install
. Followed steps required to properly have devise working and ranrails g devise:views
. - Added functionality for logged in and guest users with different views and tested the login/logout features.
- Ran
rails g migration added_user_index_to_listings
. After that, ranrake db:migrate
. This adds the user index to listings so that it is easier to code a functionality for the user to look at their listings. - Added edit and delete buttons (and paths) for the user to have the functionality to delete or edit a listing that they posted.
- Added a file to to edit listings and added
update
anddestroy
actions for listings. Added breadcrumbs to all the static pages of the site. - Added a validations for listings.