RailsCasts Pro episodes are now free!

Learn more or hide this

Tomás Charad's Profile

GitHub User: tomascharad

Site: www.tomascharad.com

Comments by Tomás Charad

Avatar

Ok, I've done it:

_calendar.html.erb:

<%= link_to "<", {date: @date.prev_month}, id: "calendar-main-month-left-arrow", remote: true %>
<%= @date.strftime("%B %Y") %>
<%= link_to ">", {date: @date.next_month}, id: "calendar-main-month-right-arrow", remote: true %>

<%= render "calendar_days" %>

_calendar_days.html.erb:
(Here you place just the rendering of the helper starting with
<%= calendar @date do |date| %>
and finishing with
<% end %>

date.js.coffee:
$("#calendar-main-month-left-arrow").attr("href", "/?date=<%= @prev_date %>&prev=true")
$("#calendar-main-month-right-arrow").attr("href", "/?date=<%= @next_date %>&next=true")
$("#calendar-days").replaceWith("<%= j render 'calendar_days' %>")
$("#calendar-main-month-span").html("<%= j @date.strftime('%B %Y') %>")

and in your controller:
if params[:date]
@prev_date = Date.strptime(params[:date],"%Y-%m-%d") - 1.month
@date = Date.strptime(params[:date],"%Y-%m-%d")
@next_date = Date.strptime(params[:date],"%Y-%m-%d") + 1.month
render "date"
end

Let me know if it helps ;), you can help yourself with episode #136 (revised)

Avatar

How did you do it to not get a hang when rendering the pdf? Are the application.css styles applied to your pdf?
I've been stuck in this a long time.

Avatar

Hi,

What I did was

invoice.attributes = row.to_hash.slice(*Invoice.attribute_names())