I am trying to make an app in Rails 4.
I have this code in my profiles show page, to show all the projects a user has created.
<div class="row">
<div class="col-md-10 col-md-offset-1">
<% Project.all_current_for_creator(@creator).sort_by(&:created_at) do |project| %>
<div class="row">
<div class="col-md-4">
<div class="indexdisplay">
<%= image_tag project.hero_image_url, width: '100%', height: '200px' if project.hero_image.present? %>
</div>
</div>
<div class="col-md-8">
<div class="row">
<div class="col-md-12">
<div class="indexheading"> <%= link_to project.title, project %> </div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="indexsubtext">
<%= truncate(project.description, :ommission => "...", :length => 250) %>
</div>
</div>
</div>
</div>
</div>
<% end %>
When I try this, I get an error that says:
SyntaxError at /profiles/3
both block arg and actual block given
Can anyone see what's wrong?
The method 'all_current_for_creator' is defined in my project.rb as:
def self.all_current_for_creator(creator)
if creator.profile.present?
creator.current.visible
else
guest_visible
end
end
I have defined three scopes in project.rb as:
scope :creator, lambda { where(@creator_profile = user.profile_id)}
scope :current, lambda { where('project.start_date >= ?', Date.today)}
scope :visible, lambda { joins(:sweep => :disclosure).where('disclosures.allusers' => 'true')
.joins(:sweep => :finalise).where('finalises.draft' => 'false') }