Facebook share button working#152
Conversation
leesharma
left a comment
There was a problem hiding this comment.
@Gauravano Thanks for the PR! 🎉
This looks pretty good (especially that html fix–thanks for that!) I've got two requests before merging:
-
It looks like you're using RubyMine/IntelliJ and checked in the config files by accident (the
.ideadirectory). Could you please remove those from the commit? Feel free to add.ideato.gitignoreif it helps. -
It looks like you've hard-coded the staging URL. We'll want this functionality to work locally, on staging, and (especially) in production, and all of those use different URLs. Is there a way to make that work without specifying a URL? If not, could we use environment variables?
Thanks again for the PR, and let me know if you have any questions about the review comments!
.idea/.generators
Outdated
| @@ -0,0 +1,8 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
There was a problem hiding this comment.
Could you remove the RubyMine files (.idea/*) from your PR? If it'd be helpful to add .idea to .gitignore, feel free to do that!
| @@ -1,6 +1,6 @@ | |||
| <div class="container"> | |||
| <div class="header"> | |||
| <h2>Create a New Wishlist</h1> | |||
app/views/wishlists/show.html.erb
Outdated
| <h2> | ||
| <%= @wishlist.name %> | ||
| <%= social_share_button_tag("Are you a hero of play? #{@wishlist.name} needs your help!") %> | ||
| <%= social_share_button_tag("Are you a hero of play? #{@wishlist.name} needs your help!",:url => "https://project-playtime-staging.herokuapp.com/wishlists/#{@wishlist.id}",desc: "Are you a hero of play? #{@wishlist.name} needs your help!") %> |
There was a problem hiding this comment.
This URL changes. Is there a way to do this without a url attribute? If not, can we get this using environment variables?
leesharma
left a comment
There was a problem hiding this comment.
Thanks for the update! This is closer, but there are still some issues (details in comments):
- It looks like this changes the ruby version to 2.3.3; we don't want to do that.
- This still hard-codes URLs. Maybe the
#wishlist_urlhelper would work here? - I also noted some style issues, but they should be easy fixes.
Again, thanks, and let me know if you have any questions!
app/views/wishlists/show.html.erb
Outdated
| <% url_share = "https://project-playtime-staging.herokuapp.com/wishlists/#{@wishlist.id}" %> | ||
| <% end %> | ||
|
|
||
| <%= social_share_button_tag("Are you a hero of play? #{@wishlist.name} needs your help!",:url => url_share,desc: "Are you a hero of play? #{@wishlist.name} needs your help!") %> |
There was a problem hiding this comment.
Some style nitpicks:
- You're using two different hash formats here (
:url => ...anddesc: ...); let's stick to the second one (key: value). - For readability, either add spaces after the commas or break this up into multiple lines.
Gemfile.lock
Outdated
|
|
||
| RUBY VERSION | ||
| ruby 2.4.1p111 | ||
| ruby 2.3.3p222 |
There was a problem hiding this comment.
We don't want to change our ruby version.
app/views/wishlists/show.html.erb
Outdated
| <% url_share = "https://project-playtime-staging.herokuapp.com/wishlists/#{@wishlist.id}" %> | ||
| <% else %> | ||
| <% url_share = "https://project-playtime-staging.herokuapp.com/wishlists/#{@wishlist.id}" %> | ||
| <% end %> |
There was a problem hiding this comment.
This still hard-codes URLs; we want this to work anywhere it's hosted.
Actually, looking at it, the url helpers would probably work: wishlist_url(@wishlist). Would that be an easier solution?
There was a problem hiding this comment.
Making helper is beneficial if wishlist_url has to be used at many placed otherwise I can optimise this URL generally too
leesharma
left a comment
There was a problem hiding this comment.
This looks really good! One last change request: rails actually has built-in _url helpers; could you remove the custom helper method? (more details in comments)
After that's done, I think this is ready to merge. 😄
|
|
||
| def wishlist_url(wishlist) | ||
| request.base_url+"/wishlists/#{wishlist.id}" | ||
| end |
There was a problem hiding this comment.
This is actually built into Rails, so you can remove this method. As an added bonus, the pre-included method will match your app configuration without extra work (ex. with subdomains, ports, friendly urls/slugs, etc.)
Here's a section of the official Rails Guides talking about _path and _url helpers.
| <%= social_share_button_tag("Are you a hero of play? #{@wishlist.name} needs your help!",:url => url_share,desc: "Are you a hero of play? #{@wishlist.name} needs your help!") %> | ||
| <%= social_share_button_tag("Are you a hero of play? #{@wishlist.name} needs your help!", | ||
| url: wishlist_url(@wishlist), | ||
| desc: "Are you a hero of play? #{@wishlist.name} needs your help!") %> |
There was a problem hiding this comment.
Looks good! 👍 I like how you broke this up into multiple lines. Much easier to read!
|
|
||
| RUBY VERSION | ||
| ruby 2.3.3p222 | ||
| ruby 2.4.1p111 |
Resolves issue #112
Example of the run at localhost
@leesharma please have a look and suggest if any improvements required. Thank You.