RailsCasts Pro episodes are now free!

Learn more or hide this

sdstoic's Profile

GitHub User: sdstoic

Comments by


Seems to be ignoring scopes. When I want to view a scoped result set and apply a Ransack filter, it views the unscoped results...

def my_queue
@search = Ticket.open.where(:analyst_id => current_user.id).search(params[:q])
@tickets = @search.result.paginate(:page => params[:page], :per_page => 25)
render 'shared/tickets.html.erb'


Did you find help for this? I, too, would like to copy the record above to create a new record - like an Excel sheet...


How could I accomplish this sort of thing with a single model? I want to create several records at once with an "Add Another Record" button, but I'm only using a single model, not nested...


I would like to export the filtered results, as well. What are those few lines I'd need? Appreciate the help...


I love Ryan's screencasts. I can't seem to get this working for me, however. The grouped_collection_select works, but my app seems to be ignoring the js.coffee file. I have the include tags in my application.html header, but still, no magic is happening. Does anyone know what I'm doing wrong?

invoices.js.coffee :
jQuery ->
facilities = $('#invoice_facility_id').html()
$('#invoice_division_id').change ->
division = $('#invoice_division_id :selected').text()
options = $(facilitys).filter("optgroup[label=#{division}]").html()
if options

_form.html.erb :

<label>Division:<font color="red">*</font></b></label>
<%= f.collection_select :division_id, Division.order(:division), :id, :division, :include_blank => true %>
<%= f.grouped_collection_select :facility_id, Division.order(:division), :facilities, :division, :id, :facility, :include_blank => true %>


Tried this, but no calendar shows up - I just get the Month Header with the FWD/BACK arrows to change the month. No data or even a blank calendar displays. There is data in my @schedules array.

<div id="calendar">
<h2 id="month">
<%= link_to "<", :month => (@date.beginning_of_month-1).strftime("%Y-%m-%d") %>
<%=h @date.strftime("%B %Y") %>
<%= link_to ">", :month => (@date.end_of_month+1).strftime("%Y-%m-%d") %>
<% calendar_for(@schedules) do |t| %>
<% t.head('mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun') %>
<% t.day (:day_method => :coursedate) do |day, schedules| %>
<%= day.day %>
<% schedules.each do |schedule| %>
<%= h(schedule.id) %>
<% end %>
<% end %>
<% end %>


I'm trying to implement this, but I'm stuck. I am carrying a param from a previous page to the index, and when I click on "Search" I get the error "Couldn't find Sla without an ID"... I know I'm doing something dumb, but can someone help me?


class PeriodBillingsController < ApplicationController
  def index
    @sla = Sla.find(params[:sla_id])
    @search = PeriodBilling.latest_billing.search(params[:search])
    @period_billings = @search.order("we_date desc").where("sla_id = ?", @sla.id)

And the view:

  <%= form_for @search do |f| %>
    <%= f.label :pe_number_eq, "Period #" %>
    <%= select("period_billing", "pe_number", (1..12), {:include_blank => true}) %>
        <%= f.label :appcode_eq, "Appcode" %>
    <%= collection_select( "period_billing", "appcode_id", Appcode.where("sla_id = ?", @sla.id), :id, :appcode, :include_blank => true ) %>
        <%= f.label :dpc_employee_eq, "Named Resource" %>
    <%= collection_select( "period_billing", "dpc_employee_id", DpcEmployee.all, :id, :fullname, :include_blank => true ) %>
    <%= f.submit "Filter Records" %>
  <% end %>

Thanks in advance for any help....