Ebad Saghar
Ebad Saghar

Reputation: 1127

Syntax Error In Controller

Getting a weird syntax error that I wasn't getting before and now I'm not sure what I did that is causing it now.

Here's what my controller looks like:

class BlogController < ApplicationController

  def cs
    @compsci = Compsci.all
  end

  def personal
    @personalb = Personalb.all
  end

  def archivedBlogs
    @compsci = Compsci.all
    @personalb = Personalb.all
  end

  def viewblg (num = 0)
    @blog = Compsci.find_by (num)
  end
end

My view where I am calling a link_to function (this is what is showing on my error page):

<div class="panel">
    <ul>
    <% @compsci.each do |blog| %>
        <li><%= link_to "#{blog.title}", viewblog_path (blog.number) %></li>
    <% end %>
    </ul>
</div>

The exact error is this:

/Users/ebadly-mac/Desktop/apps/blog/app/views/blog/archivedBlogs.html.erb:12: syntax error, unexpected ( arg, expecting keyword_do or '{' or '(' ...#{blog.title}", viewblog_path (blog.number) );@output_buffer... ... ^ /Users/ebadly-mac/Desktop/apps/blog/app/views/blog/archivedBlogs.html.erb:20: syntax error, unexpected keyword_do_block, expecting keyword_end '.freeze; @personalb.each do |blog| ^ /Users/ebadly-mac/Desktop/apps/blog/app/views/blog/archivedBlogs.html.erb:21: syntax error, unexpected ( arg, expecting keyword_do or '{' or '(' ...#{blog.title}", viewblog_path (blog.number) );@output_buffer... ... ^ /Users/ebadly-mac/Desktop/apps/blog/app/views/blog/archivedBlogs.html.erb:29: syntax error, unexpected keyword_ensure, expecting end-of-input

Upvotes: 0

Views: 475

Answers (1)

dx7
dx7

Reputation: 812

You should not put spaces between method name and parenthesis.

Upvotes: 1

Related Questions