RailsCasts Pro episodes are now free!

Learn more or hide this

sdstoic's Profile

GitHub User: sdstoic

Comments by

Avatar

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'
end

Avatar

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

Avatar

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...

Avatar

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

Avatar

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 ->
$('#invoice_facility_id').parent().hide()
facilities = $('#invoice_facility_id').html()
console.log(facilities)
$('#invoice_division_id').change ->
division = $('#invoice_division_id :selected').text()
options = $(facilitys).filter("optgroup[label=#{division}]").html()
console.log(options)
if options
$('#invoice_facility_id').html(options)
$('#invoice_facility_id').parent().show()
else
$('#invoice_facility_id').empty()
$('#invoice_facility_id').parent().hide()

_form.html.erb :

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

Avatar

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") %>
</h2>
<% 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 %>
</div>

Avatar

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?

Controller:

ruby
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)
  end  
end

And the view:

rails
  <%= 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....