Free Clone Craigslist Program Apartments
Posted : admin On 25.08.2019- Craigslist Search Program
- Free Clone Craigslist Program Apartments Los Angeles
- Free Craigslist Software
Best craigslist clone script for high traffic? Bad experiences so far. But if there is a craigslist clone script available with advanced features so my members. Trey songz free music downloads.
Features
- Image upload: paperclip (gem)
- Image upload requires ImageMagick
- Google Maps API: with the geocoder (gem)
- Figaro: for hiding API key (and other sensitive data)
Models
- User
- password
- Post
- title
- cost
- body
- image
- address
- latitude
- longitude
- user_id
Day 1 Image Upload
rails new craigslist-clone
cd craigslist-clone
git init
(add and commit)- Setup User authentication with Devise
- Add paperclip to Gemfile and
bundle install
- Generate Post model
rails g model Post title cost:decimal body:text
rails g paperclip post image
rake db:migrate
- Add paperclip code for image to Post model
- Generate posts_controller
rails g controller Posts index new show edit
- Add post routes to
config/routes.rb
using the resources heler and remove default generated routesresources :posts
- Add simple_form to Gemfile
rails g simple_form:install --bootstrap
- Add new form for Post
Add
post_params
andcreate
action to posts_controllerInstall ImageMagick
- mac -
brew install imagemagick
- c9
sudo apt-get update
sudo apt-get install imagemagick -y
- mac -
Fire up your app and navigate to
localhost:3000/posts/new
, create a new postEdit your
posts_controller
show
action andposts/show.html.erb
view to display the Post info- use
number_to_currency
andimage_tag
to render the cost and the image
- use
To do items:
- Complete full CRUD for Posts
- Associate User and Post (one:many)
- Add post validations and error rendering
- Add authorization to stop malicious editing or deleting of posts
See c9 workspace for source code (navigate to: tts-dal/rails/day_17_craigslist_clone_part_1/craigslist-clone
)
Day 2 Google Maps
- Add figaro gem to Gemfile
gem 'figaro'
- Run
bundle
- Run
bundle exec figaro install
- Create a new project in Google Maps API and get a key
- Open
config/application.yml
and add your key as an environment (ENV) variablemaps_api_key: <your_key_here>
- open
application.html.erb
and add the following script to the bottom of the head element:
- Add a div to render the map onto your
posts/show.html.erb
view:
- Open
assets/stylesheets/posts.scss
, rename the file to beposts.css
and add the following CSS:
- Open
assets/javascripts/posts.coffee
, rename the file to beposts.js
and add the following code:
- Now we need to give our Post model an address property and connect it to the map
- Generate a new migration for the posts table:
rails g migration AddCoordinatesToPosts latitude:float longitude:float address:string
then runrake db:migrate
- Now add the address property to our
posts/new.html.erb
form:
- Whitelist the new properties in your posts controller:
Craigslist Search Program
- Now add the geocoder gem:
- Add
gem geocoder
toGemfile
and runbundle
- Add
- Add the following code to your Post model (
models/post.rb
), right after the paperclip code that we added earlier:
- To render the address and marker onto the map we'll need to set the JavaScript variables using Rail's javascript_tag, add the following code to the bottom of
posts/show.erb
Free Clone Craigslist Program Apartments Los Angeles
- I went ahead and included the title, cost, and address so we could render them onto the marker as an info window
- Update your
assets/javascripts/posts.js
file with the following:
- Update your
- Open up
rails console
and delete all pre-exisiting posts withPost.destroy_all
now close rails console, run yourrails server
and create a new post.
DISABLE TURBOLINKS
Do you have to refresh the page several times for the map to load? This is because of turbolinks. Turbolinks is rails gem that conflicts with our javascript.Funny, because its intended purpose is to load pages faster. Let's kill it.
- Remove the gem 'turbolinks' line from your Gemfile.
- Remove the //= require turbolinks from your app/assets/javascripts/application.js.
- Remove the two 'data-turbolinks-track' => true hash key/value pairs from yourapp/views/layouts/application.html.erb.
Day 3 Post Search
- Open up your
application.html.erb
file and modify the navbar. In the following code we are removing the html form and adding in a rails form with ERB syntax:
- Open up the
posts_controller.rb
file and replace the index action with the following code:
Free Craigslist Software
- .search is not a regular class method for the Post model, so we'll have to create it ourselves, open up your post model
models/post.rb
and add the following code to the bottom of your model before the closingend
keyword:
Fire up your server and check it out, you should now have the ability to search for any existing posts using keywords from their titles
Discuss SQL Injection Security Exploit
Day 4 Styling
- Install the twitter-bootstrap-rails gem
- download a free theme from startbootstrap.com (we used clean blog)
- unzip the theme
- copy and paste images dir into public
- copy and paste the minified css theme into vendor/assets/stylesheets - require in application.css (e.g. require clean-blog.min)
- copy and paste the minified js file into vendor/assets/javascripts - require in application.js
- open index.html, find any google fonts, copy and paste their - import codes from fonts.google.com into application.css using @import url()
- open index.html and copy over the navbar and header areas, be sure to replace the appropriate elements with your pre-existing rails content