首页 > 解决方案 > SQLite3::SQLException:在“at”附近:语法错误

问题描述

尝试遍历我拥有的作业时,我不断收到此错误,这是代码:

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

这个异常:“SQLite3::SQLException:靠近“at”:语法错误”它没有识别行开头的“-”。我的文件是一个 .html.haml 文件。

这是作业控制器:

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

还有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

标签: htmlrubyruby-on-rails-3haml

解决方案


您的订单查询有错字:order("created at DESC")应该是order("created_at DESC")


推荐阅读