ruby on rails - error when i try to go to calendars_path ( nil can't be coerced into Fixnum) -


i have succeeded resolve problem nil can't coerced fixnum 1 :(

no block given (yield)

i know problem on index.html line 8 dont know resolve

module calendarhelper

    def calendar(date = date.today, &block)         calendar.new(self, date, block).table     end  class calendar < struct.new(:view, :date, :callback)      header = %w[monday mardi mercredi jeudi vendredi samedi dimanche]     start_day = :monday      delegate :content_tag, to: :view      def table         content_tag :table, class: "calendar"               header + week_rows         end     end      def header         content_tag :tr              header.map { |day| content_tag :th, day }.join.html_safe         end     end      def week_rows         weeks.map |week|             content_tag :tr                  week.map { |day| day_cell(day) }.join.html_safe             end         end.join.html_safe     end      def day_cell(day)         content_tag :td, view.capture(day, &callback), class: day_classes(day)     end      def day_classes(day)         classes = []         classes << "today" if day == date.today         classes << "notmonth" if day.month != date.month         classes.empty? ? nil : classes.join(" ")     end      def weeks         first = date.beginning_of_month.beginning_of_week(start_day)         last = date.end_of_month.end_of_week(start_day)         (first..last).to_a.in_groups_of(7)     end end 

end

controler calendars_controller.rb

def index     @content_calendars = calendar.all     @content_calendars_by_dates = @content_calendars.group_by(&:published_on)     @date = params[:date] ? date.parse(params[:date]) : date.today   end     def show     @calendar = calendar.find(params[:id])   end 

index.html

 1     <%= calendar @date |date| %>  2       <%= date.day %>  3    4    <!--# <%= debug(params) if rails.env.development? %>  5      --><% if @content_calendars_by_dates[date] %>  6         <ul>  7             8           <% @content_calendars_by_dates[date].each |article| %>  9                <li><%= link_to calendar.event, article %></li>  10          <% end %>  11           12         </ul>  13       <% end %>  14     <% end %> 

you may want check out ryans calendar app ideas https://github.com/railscasts/213-calendars-revised


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -