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:migrateto autogenerate a Schema. - Make models and assign them corresponding to their relations.
- Make controllers and set up routes using the
config/routes.rbfile. - Add the root index file and corresponding stylesheets.
- Make views and define them in the controller. Add them to the
routes.rbfile and tag them into links into the rootindex.html.erbfile. - Define categories and subcategories in a way that would look good into a URL (breadcrumb).
- Define data for
config/seeds.rbfile and runrake db:seedto make sure that duplicate data is not being stored and the CRUD operations are running in the Database. - Use
rails con the terminal and type<Record Name>.allto 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 theCategoriesControllerand 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 theSubcategoriesControllerand made a basicshow.html.erb. - For the listings, we need the CRUD operations. So, add
resources :listingstoroutes.rbfile and then runrake routes. - To use the listings CRUD operations, add a link to
index.html.erb, then define the new function in theListingsControllerand 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
createaction in theListingsController. - Another private method called
listing_paramswas 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_listingsso that it is possible to have fields for categories and subcategories increate_listingform. - Added code to
changefunction and ranrake db:migrate. - Added
find_by_categorymethod to select subcategories based on the category chosen and added a post request toroutes.rbfile. - There is no use for loading JS every time so
//=require_tree.was removed fromapplication.jsfile. - Added code to include js in the view, used
initializerstoprecompile jsfile to select subcategories based on the category chosen and fixed bugs inroutes.rbandSubcategoriesController. - 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
geocodergem for search functionality for the listings and added code tolistings.rbto join the details of the location. - Ran
rails g migration add_lat_long_to_listingsand added code to change function for the type of latitude and longitude. After that, ranrake db:migrate. - Added code to
ListingsController,Listings modelandindex.html.erbto support search functionality for all the listings using the data present. - Added
devisegem 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
updateanddestroyactions for listings. Added breadcrumbs to all the static pages of the site. - Added a validations for listings.