i try to write a function get meeting details from table online meeting rooms i specific 3 parameter: start_date & end_date & username this function should return api in formate : details[Name] = ... & details[...] = ... as following in code In database we have multiple colon and data i want only name and sheduled_on and condition between 2 date as parameter I dont understand what is the error in my code ?
Error :
hh
2
1
[FedenaRescue] No method error undefined method `each' for #<BbbMeetingRoom:0x7fd0261d3be0>
NoMethodError (undefined method `each' for #<BbbMeetingRoom:0x7fd0261d3be0>):
vendor/plugins/madrasatie_api/app/controllers/api/meetingapi_controller.rb:35:in `get_meeting'
passenger (4.0.59) lib/phusion_passenger/rack/thread_handler_extension.rb:74:in `process_request'
passenger (4.0.59) lib/phusion_passenger/request_handler/thread_handler.rb:141:in `accept_and_process_next_request'
passenger (4.0.59) lib/phusion_passenger/request_handler/thread_handler.rb:109:in `main_loop'
passenger (4.0.59) lib/phusion_passenger/request_handler.rb:455:in `start_threads'
passenger (4.0.59) lib/phusion_passenger/request_handler.rb:449:in `initialize'
passenger (4.0.59) lib/phusion_passenger/request_handler.rb:449:in `new'
passenger (4.0.59) lib/phusion_passenger/request_handler.rb:449:in `start_threads'
passenger (4.0.59) lib/phusion_passenger/request_handler.rb:448:in `times'
passenger (4.0.59) lib/phusion_passenger/request_handler.rb:448:in `start_threads'
passenger (4.0.59) lib/phusion_passenger/request_handler.rb:447:in `synchronize'
passenger (4.0.59) lib/phusion_passenger/request_handler.rb:447:in `start_threads'
passenger (4.0.59) lib/phusion_passenger/request_handler.rb:208:in `main_loop'
passenger (4.0.59) helper-scripts/rack-preloader.rb:161
Rendering single_access_tokens/500.xml
My Code :
class Api::MeetingapiController < ApiController
require 'net/http'
require 'json'
require 'net/https'
require 'securerandom'
helper_method :https
def get_meeting
logger.info "hh"
@start_date = params[:start_date].present? ? params[:start_date].to_date : @local_tzone_time.to_date
@end_date = params[:end_date].present? ? params[:end_date].to_date : (@local_tzone_time).to_date
@user = User.active.first(:conditions => ["username LIKE BINARY(?)",params[:username]])
@details = []
if @user.admin?
@rooms = OnlineMeetingRoom.find_all_by_date(:conditions=>"( Date(scheduled_on) between '#{@start_date}' and '#{@end_date}' or Date(scheduled_on) = '#{@start_date}' or Date(scheduled_on) = '#{@end_date}' )",:order=>"id DESC")
logger.info "2"
else
logger.info "here1"
@rooms = OnlineMeetingRoom.valid_meetings
logger.info "here2"
@rooms = @rooms.rooms_for_user(@user) unless @user.admin?
logger.info "here3"
@rooms = @rooms.scheduled_on_gte(@start_date).scheduled_on_lte(@end_date.end_of_day)
logger.info "here4"
end
logger.info "1"
@rooms.each do |r|
room = Hach.new
logger.info "555"
room["Name"] = r.name
logger.info "666"
room["Created_by"] = @user
logger.info "999"
room["Shedule on"] = r.sheduled_on
logger.info "000"
@details << room
end
respond_to do |format|
format.json {render :json=>{ :data => {:details =>JSON.parse(@details.to_json.gsub("'", %q(\\\')))}, :statusCode => 200, :statusMessage => "OK" }}
end
end
end
Aucun commentaire:
Enregistrer un commentaire