Skip to content

Instantly share code, notes, and snippets.

@Colt
Created October 28, 2013 20:27
Show Gist options
  • Select an option

  • Save Colt/7204002 to your computer and use it in GitHub Desktop.

Select an option

Save Colt/7204002 to your computer and use it in GitHub Desktop.
GroupGo Refactoring Notes

#GroupGo Refectoring Notes

In your create method in the Entries Controller, remove this code:

	if params[:email]
		puts "*"*50
		#p params
	end		

Also, remove this in your Submit method:

	puts "**"*50
	#p entry

as well as this line:

	groups = "where user name should be"

Your submit method is a bit long(debatable), so maybe you could move most of it into a seperate method, something like this:

def submit
	send_email  //make a new mrthod
	redirect_to entry_path(entry.id)
end

Your index.html.erb view in your entries folder has a ton of commented out code you should get rid of.

I would also add some helpful comments to explain some of the complicated parts when you get a chance. What does this do?

	render nothing: true, status: 200

You have an unused JS script called entries.js It's just a bunch of commented out code that you never call.

You could work on refactoring this javascript method using jquery instead:

	function deleteList(emailList) {
var email = document.getElementById(emailList);
var number = email.rows.length;
    for(var i=0; i<number; i++) {
        var row = email.rows[i];
        var chkbox = row.cells[1].childNodes[0];
        if(null != chkbox && true == chkbox.checked) {
            email.deleteRow(i);
            number--;
            i--;
          
	document.getElementById('emailTotal').innerHTML= number;

        }
	 }
}

As far as the actual layout of the site, I would make the Register button on the homepage more distinct. It's not very clear what to do when a user first goes to your site. I know you didn't have much time to work on that stuff…

Your HTML needs proper indentation! It's hard to read! For Example:

<body>
<div class="container">
 <div style="float: left">
   <!-- @entry.where_to</br>
   @entry.what_for</br> -->
   <h3>Invite your friends!</h3>
   <input type="textbox" id="entry1" size="30"/>
		<input type="hidden" id="entry_id" name="entry_id" value="<%= @entry.id %>"></p>
   <input type="button" value="Add Email" onclick="addList('EmailListForm')" />

   <input type="button" value="Delete Email" onclick="deleteList('EmailListForm')" />

   <table id="EmailListForm" width="350px" border="1">
    
   </table>
   Emails in list
   <% @groups.each do |group| %>
   <li><%= group.email %></br></li>
   <% end %>
   <p>
   <form action="/submit">
    <input name="entry_id" type="hidden" value="<%= @entry.id %>">
    <button> SEND EMAILS! </button>
   </form>
 </div>

 <div style="float: center">
   <%= form_tag("/message", method: "get") do %>
  <input type="hidden" id="entry_id" name="entry_id" value="<%= @entry.id %>">
   <%= label_tag(:message, "Leave a message:") %><p>
   <%= submit_tag("Post Message") %>
   <%= text_area_tag(:message, "", :size => "40x5")%>
   
   <% end %>
 </div>
 <div style="float: left">
 <h4>Link to this page!</h4>
   copy this url
   <input type="textbox" size="20" value="http://groupgo.herokuapp.com/entry/<%= @entry.id %>" id="urlmaker" />
 <table class="table">
 </div>
 </br>
 </br>
 </br>
 <caption><h3>Messages Left</h3></caption>
 <thead>
     <tr>
   <% if @messages %>
   <% @messages.each do |message| %>
   	<th><blockquote><%= message.message %></blockquote></th>
   </tr>
 </thead>
<% end %> 
<% end %>
</div>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment