Created
June 21, 2009 17:35
-
-
Save eqdw/133582 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- RENDERED PARTIAL > | |
<tr> | |
<td><%=h bug.user.company_name %> </td> | |
<td>Submitted by <%=h bug.submitter %></td> | |
<td><%=h bug.subject %> </td> | |
<td> <%=h truncate(bug.description.gsub(/<.*?>/,''), :length => 80) %> </td> | |
<td> <%= link_to 'Show', bug %> </td> | |
<% if session[:admin] %> | |
<td> <%= link_to 'Edit', edit_bug_path(bug)%> </td> | |
<td> <%= link_to 'Destroy', bug, :confirm => 'Are you sure?', | |
:method => :delete %> </td> | |
<% end %> | |
</tr> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- THIS IS THE VIEW > | |
<h1>Index:</h1> | |
<% form_tag :action => "index" do %> | |
<fieldset> | |
<legend>Enter Search Criteria</legend> | |
<div> | |
<label for="Company">Company Name:</label> | |
<%= collection_select( :user, :company_name, User.all, | |
:company_name, :company_name, options = {:prompt => "-Select a Company"}) %> | |
</div> | |
<div> | |
<label for="Username">Username:</label> | |
<%= collection_select( :user, :name, User.all, :name, :name, | |
options = {:prompt => "-Select a Username"}) %> | |
</div> | |
<div> | |
<label for="Submitter">Submitted By:</label> | |
<%= collection_select( :bug, :submitter, Bug.all, :submitter, | |
:submitter, options = {:prompt => "-Select a Submitter"}) %> | |
</div> | |
<div> | |
<%= submit_tag "Search" %> | |
</div> | |
</fieldset> | |
<%end%> | |
</div> | |
<div id="bug-list"> | |
<% unless @bugs == nil %> | |
<h1> Listing bugs:</h1> | |
<table> | |
<%= render(:partial => "shared/bug", :collection => @bugs) %> | |
</table> | |
<%end%> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The action | |
# Thanks, burke! | |
def index | |
@bugs = nil | |
if request.post? | |
mappings = Hash.new{|k,v|v} | |
allowed_user_attrib = [:company_name, :name] | |
allowed_bug_attrib = [:submitter] | |
user_attrib = params[:user].reject{|k,v| ! allowed_user_attrib.include?(k)} | |
bug_attrib = params[:bug].reject {|k,v| ! allowed_bug_attrib.include?(k)} | |
if user_attrib | |
user = User.find(:first, :conditions => user_attrib) | |
bug_attrib.merge!({:user_id => user}) | |
end | |
@bugs = Bug.find(:all, :conditions => bug_attrib) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment