Home > OS >  SQLite3::SQLException: near "at": syntax error [closed]
SQLite3::SQLException: near "at": syntax error [closed]

Time:09-17

I keep getting this error when trying to loop through the jobs i have , here is the code :

- @jobs.each do |job|
  %h2= job.title
  %p= job.company 

this exception the :"SQLite3::SQLException: near "at": syntax error" its not identifying the "-" at the beginning of the line. My file is a .html.haml file.

This is the job controller :

class JobsController < ApplicationController
    before_action :find_job, only: [:show, :edit , :update , :destroy]

    def index
        @jobs=Job.all.order("created at DESC")
    end 

    def show 
    end

    def new
        @job=Job.new 
    end

    def create 
        @job=Job.new[job_params]
        if(@job.save)
            redirect_to @job
        else 
            render "New"
        end 
    end

    def edit
    end 

    def update
    end

    def destroy
    end

    def job_params
        params.require(:job).permit(:title , :description , :company , :url)
    end

    def find_job
        @job=Job.find(params[:id])
    end

end

also the application_job

class ApplicationJob < ActiveJob::Base
  # Automatically retry jobs that encountered a deadlock
  # retry_on ActiveRecord::Deadlocked

  # Most jobs are safe to ignore if the underlying records are no longer available
  # discard_on ActiveJob::DeserializationError
end

CodePudding user response:

Your order query has a typo: order("created at DESC") should be order("created_at DESC")

  • Related