FirehoseCommunity / DEFCON

6 stars 4 forks source link

Not yet ready to merge--Added javascript to posts.js for popover/tooltip function & code to index.html.haml #144

Open NKHolton opened 8 years ago

NKHolton commented 8 years ago

This is to fix Issue #136. All tutorials I can find on this give an option either for a tooltip or a popover which seem very similar. They all seem to implement it either making the language you want a tooltip/popover for into a button or a link and it seems like we want neither in this case. Tried looking at Twitter Bootstrap documentation and I'm just not finding it detailed enough so went looking at other tutorials such as one on W3Schools. Needing some direction and hoping to discuss in tonight's meeting...

On a somewhat related note- I'm still not resonating with the Gemfile.lock changes. Ken- you mentioned that it was something that Robert implemented? I tried not to push those changes to this pull request but it appears I ended up pushing them. Should I just run a bundle install to fix?

kenmazaika commented 8 years ago

Thumbs up from me.

Yeah, Robert changed the Gemfile, but never ran a bundle install. This left extra stuff in there that shouldn't be. Your code makes the project better than it was.

I'm happy to merge this if it's ready.

kenmazaika commented 8 years ago

Things to note:

<div data-toggle="tooltip" data-placement="right" title="<%= post.user.github_handle %>" >
  <%= post.user.email %>
</div>

Convert to HAML.

%div.userHandle{"data-toggle": "tooltip", "data-placement": "right", "title": post.user.github_handle}
  = post.user.email
// CSS file
.userHandle {
  width:300px; background-color:purple;
}

To give yourself a github handle

rails console
u = User.first
u.update_attribute(:github_handle => 'yourhandle')
exit
NKHolton commented 8 years ago

I'm finally getting to this right now but in the console and trying to add a github handle to User.first and seeing this: irb(main):006:0> u.update_attribute(:github_handle => 'FirehoseCommunity/DEFCON') ArgumentError: wrong number of arguments (1 for 2) from /home/vagrant/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/activerecord-4.2.0/lib/active_record/persistence.rb:235:inupdate_attribute' from (irb):6 from /home/vagrant/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/railties-4.2.0/lib/rails/commands/console.rb:110:in start' from /home/vagrant/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/railties-4.2.0/lib/rails/commands/console.rb:9:instart' from /home/vagrant/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:68:in console' from /home/vagrant/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:39:inrun_command!' from /home/vagrant/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/railties-4.2.0/lib/rails/commands.rb:17:in <top (required)>' from bin/rails:4:inrequire' from bin/rails:4:in <main>'

Am I typing it wrong?

Also noticed that when NOT putting post.user.github_hande in " " the tooltip doesn't show up but then adding them makes the tooltip work although it just currently displays "post.user.github_handle" exactly so I'm trying to add an actual github handle instance in the database.

kenmazaika commented 8 years ago

Use the method update_attributes not update_attribute. That should get you squared away.

NKHolton commented 8 years ago

Thanks, Ken, that worked. Got it into the database but having issues with it not showing the tooltip if I just do post.user.github_handle with no quotes. The tooltip only pops up when I surround it with " ". Trying to figure it out... Also do we want it to show the full link to github in the tooltip so the user can easily click on it, go to github and see the code, or just the actual handle '.../XYZ' ?

kenmazaika commented 8 years ago

I think just including the github handle, without a link or anything else would be a good first step.

NKHolton commented 8 years ago

I can't believe I'm still having trouble with this but I am. My issues:

-CSS class is not being recognized within the HAML. Ken, you said it would look like "%div.userHandle......." in the HAML then in CSS it'd be '.userHandle........". In the HTML to HAML online converters I try it actually leaves out the div completely and just says to start the HAML with ".userHandle......." so that's one thing I want to note. Even in doing so though the CSS is still not being recognized. I tried it in Nomster with HTML and the tooltip recognizes the database fields and displays the tooltip but the CSS is also not being recognized in there either and I can't figure out why.

I've searched online for some help with "getting HAML to recognize a rails database field" but don't know if that's really the right search?

Also, the documentation on getbootstrap.com says "For performance reasons, the tooltip and popover data-apis are opt in, meaning you must initialize them yourself."...so does that mean that some JS does need to be written?

kenmazaika commented 8 years ago

Haml assumes a tag is a div if nothing is specified. So:

.whatever

equals

%div.whatever

Why don't you look on YouTube to see if there are any good videos that cover how HAML works?