sid d

Joined

420 Experience
0 Lessons Completed
0 Questions Solved

Activity

 Fpclass(id: integer, name: string,  start_time: time)

 Fpclass.first.start_time
 # 2000-01-01 01:01:00 UTC

I'm having problem with comparing time field while fetching results as you've seen above its storing all date and time in database even though i mentioned Time field while creating. Does anyone had faced similar kind of problem before ? Can you share me how to approach with time fields in active record, or am i doing something wrong ?

Finally what i need ?

 Fpclass.where('start_time>?', Time.now.strftime("%H %M"))

I didnt know how i missed this part. Thanks

Hi Chris,

I've seen simple_calendar ruby gem and i stuck at sort_by method (calendar.rb)

def events_for_date(current_date)
     if events.any? && events.first.respond_to?(:simple_calendar_start_time)
        events.select do |e|
          current_date == e.send(:simple_calendar_start_time).in_time_zone(@timezone).to_date
        end.sort_by(&:simple_calendar_start_time)
     else
        events
    end
 end

May be its stupid question or i dont know and i also tried tracing using pry for this method but i cannot understand how here sort_by works ..! Do you mind give me some idea on this how events are sorting here.

Posted in Help needed on how to create spatial indexing

Screencast would be great. Active record postgis adapter documentation fine too.

Posted in Help needed on how to create spatial indexing

I don't even know about PostGIS exists. I'm going through documentation and it appears i come up with poor documentation on PostGIS.

More or less i need to do this thing, meanwhile if you can have any help for me how to go with this, i'll be much glad with that. Thanks so much Chris

Posted in Help needed on how to create spatial indexing

Presently i have a list of the places what i've looking for and latitude / longitude numbers for them and i come up with somewhere about spatial indexing to search for nearest locations within my database but i've got not much help on this anywhere on internet how to go forward on rails application.

I'll be pretty much glad, if i get some help from you guys.

Posted in Dealing with Recursive Models

User wants to search for classes nearby according to date similar to classpass

Backend

Form fields for creating class by admin::
1) Name
2) Start Date ( Class start date)
3) End Date
4) Recursive?

class Fpclass < ActiveRecord::Base
   after_create :build_ice_cube_params
   has_many :recursivedates

 private
  # This method is used to push dates between start date to end date (weekly) to recursivedates
  def build_ice_cube_params
            search_dates.each do |date|
        recursivedates << Recursivedate.create(:ondate => date)
     end
     end
end

Frontend ref

Implemented search using Ransack

class FiltersController < ApplicationController
  def search
    @c = Fpclass.ransack(params[:q])  # params[:q][:recursivedates_ondate_eq]
    @fpclasses = @c.result(distinct: true)
  end
end

Example how it'll work

1) Admin creates class that'll held on every sunday until 2 months using (start date and end date )
2) Fpclass saves all data (name, startdate, enddate etc.,) and creates recursivedates (Between dates like 1st of july, 8th july, 15th july ....)
3) Getting fpclasses at search page using ransack on (recursivedates model)

Problems i've facing
1) When admin edits form then all fresh dates dumped into recursivedates model along with old ones
2) When admin gives longer dates(from 2015 to 2020) (Sql insertions are more)
3) Searching kills time
4) Hard to implement conditions at Reserve button as shown in ref image

Can there be any alternative approach or can you let me know if any mistakes i've done ?

Requirement::

We have implemented Passport where any user can subscribe to this passport. I want to restrict subscriptions after 20 subscriptions happen. How can we go with this.

Any ideas ?

Posted in Recurring Events

I've found out Recurring Select which best suits my needs. It would be nice if we had a screencast on this

Posted in Problem with upgrading to Rails 4.2.2

Try installing rails separately and bundle again. ( Remove Gemfile.lock if problem persist and bundle )

Posted in Recurring Events

# Model 
def Event
  WEEKDAYS = ['sunday', 'monday', 'wednesday', 'thursday', 'friday', 'saturday']

end

# Migration 
create_table :events do |t|
 t.column recurring, default: false 
 t.column start_date:datetime
end

# Console
Event.create(:name => 'Avengers', :recurring => true, :week_days => ['Sunday', 'Wednesday'])
Event.create(:name => 'Dummy movie', :recurring => false)
Event.today  #Today events ( Dummy movie, Avengers)
Event.between(tomorrow, end_of_the_month) # ( Avengers, Avengers, Avengers, ...... )  
  • Can anyone suggest best way to implement recurring Events and Fetching of Events according to Weekdays ?

Posted in Active Record Associations

def partner
  has_many :centers
end

def center
 has_and_belongs_to_many :classes
 belongs_to :partner
end

def fpclass
  has_and_belongs_to_many :centers
end
  • I'd like to access all fpclasses that partner belongs to? ( Is there any other way to access except to provide another foreign key named partner_id on fpclass ) Any ideas really helpful.

Really helpful, thanks for screencast