我对jquery的了解很少.我已经提到了下面的脚本
var header = $('.time'+col).text();
alert(header);
我得到的字符串为"109:00AM",如何获得第一封信如1.你能帮助我吗?
我正在使用文本编辑器(wysihtml5).我在数据库中保存数据时遇到问题.如果我输入的行数超过20行.它显示错误,如"Mysql2 ::错误:第1行的列'描述'的数据太长了."我正在使用rails4.
在模型中
class News < ActiveRecord::Base
    attr_accessible :name,:published_on,:description
    #associations
     validates :name,           presence: true
     validates :published_on,   presence: true
     validates :description,    presence: true
end
在控制器中
class NewsController < ApplicationController
  layout :setting_layout
  before_action :set_news, only: [:show, :edit, :update, :destroy]
  # GET /news
  # GET /news.json
  def index
    @news = News.all
  end
  # GET /news/1
  # GET /news/1.json
  def show
  end
  # GET /news/new
  def new
    @news = News.new
  end
  # GET /news/1/edit
  def edit
  end
  # POST /news
  # POST /news.json
  def …我正在使用rails 4.我有员工出勤模式.因为我必须单独上传.csv文件.它不允许任何其他格式.那么,如何验证文件格式.导入的文件是否不是csv.
模型
class EmpAttendance < ActiveRecord::Base
    attr_accessible :emp_id,:in_time,:out_time,:date,:status
    def self.import(file)
            CSV.foreach(file.path, headers: true) do |row|
            @emp_attendance  = EmpAttendance.find_by_emp_id_and_date(row['emp_id'],row['date']) || EmpAttendance.new
            @emp_attendance.emp_id                = row['emp_id']
            @emp_attendance.in_time               = row['in_time']
            @emp_attendance.out_time              = row['out_time']
            @emp_attendance.status                = row['status']
            @emp_attendance.date                  = row['date']
            @emp_attendance.save!
        end
    end
end
调节器
def import
    if params[:file].present?   
     EmpAttendance.import(params[:file])
     flash[:notice] = "Sucessfully Created."
     redirect_to emp_attendances_path
    else 
     flash[:error] = "No File Chosen"
     redirect_to emp_attendances_path
    end 
 end
查看(Index.html.erb)
<div class='row-fluid clear'>
  <div class='box gradient'>
    <div class='title'>
      <h3 style='margin-left:1em'>Add Driver Details</h3>
    </div>
    <div class='content'>
     <% if …