Showing posts with label acts as votable. Show all posts
Showing posts with label acts as votable. Show all posts

Friday, April 1, 2016

Week 11 - Dribble App - carrierwave, acts_as_votable, fog-aws, mini_magick, devise, simple_form, haml




Today I finished work on the Dribble App.  It is a cool way to display artwork and anything visually stunning. (i.e. Wonder Woman)  Since it supports pictures and gifs, I had to again use paperclip, I mean carrierwave.  Paperclip didn't work for me for the 3rd time.  It works well locally but integration with S3 did not compute.

I learned some cool new things in this app.  Like in the picture below, on the right I can display a random post.  It was done with one simple line of code.






While working on a bug for a few hours I ran into a solution that wasn't covered by Mackenzie Child. When you push this app to heroku, you will not have a database.  There is code in post/show.html.haml that is looking to display a post that will break because there aren't any posts.

The code looks for a post that does not have the same user_id as the post that is displaying, puts it into a collection and gets a random one to display.  So I just thought, well it should only show a post if there is more than 1 post.


So in line 1 I added an if statement. if Post.count > 1 display the random post else display the sentence You have the first post.


It is not a big deal, since I can populate the database and it takes just one to keep the app from breaking, but in my book its a bug that had to be fixed.

Functionality I would like to add:
1. Better picture formatting so each pic on index page is the same size
2. Search function.
3. Rich text formatting
4. Social media shareability
5. Make pictures 30%-50% bigger. Move random box view down to lower right corner.
6. Add a large version of the picture to have as a background image for each post.
7. Tie dislike button to comments, so a user has to leave a comment if disliking a post.

Tune in next week, for the final app.

Kenyacode

Friday, February 19, 2016

Week 4 - Pinterest app part 2 - jQuery, Haml, Simple form, Bootstrap-sass, Paperclip

Click Here to go to Website
Ok, I had to fly out of town but I found a great co-working space in Chandler, AZ, just 20 min from Phoenix.  Stop by if you are ever in town.  Its called gangplank


So yesterday and today I have been working on changing this app from paperclip to carrierwave and setting the env variables.  I did some stupid rookie mistakes! I put code in a place where it didn't belong.  I was following a fix from stackoverflow that did not work.  I forgot to remove all the code from the fix that didn't work.  It kept throwing errors and I didn't figure it out for 2 hours.

Now that I got that fixed, I simply had to create a prod database on amazon s3 and set that in my env and on heroku config:set and I was up and running.

Note: make sure you use the same wording when setting vars. From your computer to your app to heroku.  I had 2 sets, one upper case and one lower case.  I now have 4 working apps and it only took me... 5 or 6 weeks.  Yikes!

I did have to help out some family here in Arizona for a few days but I'm still 2 weeks long.  Well the movie app is next and I'm excited about this one.  I have my own idea for a tv show review app that I really want to build.

Features I would like to add:
1. Search function
2. Multiple image upload. Auto img rotation on show view.
3. Social media shareability
4. Facebook log in.
5. Add a splash page.

See you next week,

Kenyacode

Tuesday, January 19, 2016

Week 2 - Reddit Clone - Bootstrap Sass, Acts as votable, Simple form

Click here to open in a new window
Today I finished Mackenzie Childs Reddit Clone app from his 12 in 12 challenge.  That's build 12 apps in 12 weeks to teach yourself Ruby On Rails.

After the blog app I finished yesterday, this app didn't seem that different.  This is a Reddit type app that looks a lot like a blog but users add web links with a title.  The site also has the ability to vote on each link.  The highest rated link is shown first in the index.

This is due to the acts as votable gem.

<% @links.order(cached_votes_up: :desc).each do |link| %>
  <div class="link row clearfix">
    <h2>
      <%= link_to link.title, link %>
      <small class="author">Submitted <%= time_ago_in_words(link.created_at) %> by <%= link.user.name %></small>
   

    <div class="btn-group">
      <a class="btn btn-default btn-sm" href="<%= link.url %>">Visit Link</a>
      <%= link_to like_link_path(link), method: :put, class: "btn btn-default btn-sm" do %>
        <span class="glyphicon glyphicon-chevron-up"></span>Upvote<%= link.get_upvotes.size %>
      <% end %>
      <%= link_to dislike_link_path(link), method: :put, class: "btn btn-default btn-sm" do %>
        <span class="glyphicon glyphicon-chevron-down"></span>Downvote<%= link.get_downvotes.size %>
      <% end %>
    </div>
  </div>
<% end %>

One thing I have had a hard time with is css.  While doing this app and the blog app, I have learned so much more about css and sass.  Bootstrap-sass is a gem I use and its great for organizing the rules. It helps me to see how the rules are applied.

I was able to load this app with a seed file as well which makes the app look great right out the box. Visit here

Well its week one and I have already finished two apps and I have published them on Heroku.  Take a look, leave a comment below and check out my github page for more apps.  Follow this blog as I take the journey from novice to working web developer.  Lets see if I can finish these 12 apps in 6 weeks.

Features I would like to add:
1. Social media shareability
2. Display who submitted the comment
3. Posting pictures & gifs, videos.
4. Rich text formating
5. Search function
6. Social media shareability

Kenyacode