RiCal add_attendee issue - ruby-on-rails

I am using RiCal gem to create calendar event in my ROR project. The issue i have is when i add attendee it adds the attendee as .
ATTENDEE:mailto:sanjay.swain#in.ibm.com
ATTENDEE:mailto:sanjayswa#gmail.com
But I want ATTENDEE as
ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=
TRUE;CN=sanjay.swain#in.ibm.com;X-NUM-GUESTS=0:mailto:sanjay.swain#in.ibm.c
om
with ROLE, PARTSTAT etc.. Is there a way to get this result using RiCal gem..

I found the solution. Here is what I have done:
options = {'CUTYPE' => 'INDIVIDUAL','RSVP' => 'TRUE','ROLE' => 'REQ-PARTICIPANT','PARTSTAT' => 'NEEDS-ACTION','X-NUM-GUESTS' => '0'}
attendee_property = RiCal::PropertyValue::CalAddress.new(nil, :value => "mailto:"+attend, :params => options)
event.attendee_property = attendee_property

Related

Rails - How To Check if Defined before adding into new Object?

I'm working with the Amazon Product Advertising API and I'm trimming its responses within my controller to render customized JSON, but its responses change a lot depending on the product category, so I need to write code that can catch all of the ways it changes. I only need a few pieces of data, so how can I simply check to see if those pieces exist within Amazon's API response before including them in my own custom JSON?
Note: I'm using this gem to integrate with Amazon's API. It returns the API responses in its own objects.
#results = (Amazon's API response)
#custom_response = []
#results.items.each do |product|
#new_response = OpenStruct.new(
:id => product.asin,
:source => "amazon",
:title => product.title,
:price => #product_price,
:img_small => #images[0],
:img_big => #images[1],
:category => product.product_group,
:link => "http://amazon.com/" )
#custom_response << #new_response
end
You can try something like this:-
#new_response = OpenStruct.new(:source => "amazon", :link => ".....")
#new_response.id = product.asin if product.asin.present?
#new_response.title = product.title if product.title.present?
other attributes....

How do you use the Gibbon Gem to automatically add subscribers to specific interest groups in MailChimp?

I'm trying to figure out how I can use the Gibbon gem in Rails to automatically add subscribers to specific interest groups in MailChimp?
I've found this article which details a non-Rails method for doing so: http://roman.tao.at/uncategorized/mailchimp-api-listsubscribe-listbatchsubscribe-and-groups/
I'd like to figure out how to implement that functionality using the Gibbon gem: https://github.com/amro/gibbon
FYI, I'm also a novice with both MailChimp and Rails.
Finally, after hours of perusing through code. I've found the example I'm looking for!
Thanks to TJ Moretto for providing this on a Google Groups thread:
I'm using the gibbon gem, but ran into the same types of issues.
Here's how I had to format the parameters to finally get this to work:
gb.list_subscribe({:id => "#{list.id}",
:email_address => user.email,
:update_existing => true,
:double_optin => false,
:send_welcome => false,
:merge_vars => {'FNAME' => "#{user.first_name}",
'LNAME' => "#{user.last_name}",
'GROUPINGS' => {0 => {'id' => grouping.id, 'groups' => "#{challenge.name}"}}}
})
Hope that helps.
Mailchimp Team - based on the number of issues that everyone runs into
when trying to do this (across all programming languages), I suggest
you update the API documentation to be more clear.
Update for version 2.0 of the MailChimp API and version 1.0 of Gibbon (For #Calin and posterity). Here are the necessary changes from the previous version. The API object is accessed like this now:
gb = Gibbon::API.new
And list methods like so:
gb.lists.subscribe(params)
Finally the :email_address parameter has been replaced by the :email parameter, which should be given a value of the following form: The value should itself be a hash with one key, either 'email' or 'leid', and the value should be either the email address of the subscriber or MC's unique identifier (LEID) for the subscriber.
So a full subscription call might look something like this:
gb = Gibbon::API.new
gb.lists.subscribe(:id => "ed6d1dfef4",
:email =>
{ "email" => "example#domain.com" },
:merge_vars =>
{:groupings =>
{
0 => { :id => "95", :groups => ["Some Group", "Another Group"]},
1 => { :id => "34", :groups => ["A Third Group"]}
}
},
:update_existing => "true",
:double_optin => "false",
:replace_interests => "false")

AND OR filter in Ruby on rails

I have a question: how do i write 2 conditions in filters params? :page_path.eql => "/teams/1" or :page_path.eql => 'teams/2'
it works for one condition, but dont work with two:(
output = Exits.results(profile, :filters => {:page_path.eql => "/teams/1"})
Try this
output = Exits.results(profile,:filters =>{:page_path.contains => "^/teams/[1|2]$"})
you can also try shorthand
output = profile.exits(:filters =>{:page_path.contains => "^/teams/[1|2]$"})
with date options
output = Exits.results(profile, :filters => {:page_path.contains => "^/teams/[1|2]$"},:start_date => Date.new(2012,8,13),:end_date => Date.today)
or
output = profile.exits(:filters => {:page_path.contains => "^/teams/[1|2]$"},:start_date => Date.new(2012,8,13),:end_date => Date.today)
This works for me
use contains instead of matches I think it does not understand regex.

Problem with jQuery in rails

How create a link_to_remote in a jQuery script where url need a parameter that is a javascript variable.
I need create a link_to_remote in pure jQuery.
Thanks in advance
You'll want to use the :with parameter with link_to_remote:
link_to_remote( args[:title],
:update => args[:update],
:url => { :action => args[:action],
:id => id,
:starting => args[:starting]
},
:with => "'filter[viewer_id]=' + $('filter_viewer_id').value",
:loading => "Element.hide('#{args[:update]}');Element.show('#{args[:loading]}')",
:complete => "Element.show('#{args[:update]}');Element.hide('#{args[:loading]}')" )
Notice how I am sending the filter_viewer_id by getting it's value from a form field with jQuery. If you don't need that level of detail, just pass the name of your javascript variable.
Like this:
<%= link_to_remote('Hello', :url => "/test?id='+ id +'&test=true") %>
This will result in:
# => Hello
Very little info on your post. Are you using Rails 3? If so, did you check the jquery-rails gem out?
Best regards,
-- J. Fernandes

Ruby on Rails / Yellow Maps For Ruby Plugin woes

Okay I've read through the plugin comments and the docs as well and I have yet to come up with an answer as to how to do this. Here's my problem I want to use the :info_window_tabs and the :icon option, but I don't know what format to pass my information in. According to the documentation the following code should be correct. Here's my code:
#mapper.overlay_init(GMarker.new([map.lat, map.lng],
:title => map.name,
:info_window_tabs => [
{:tab => "HTML", :content => #marker_html},
{:tab => "Attachments", :content => "stuff"}],
:icon => {
:image => "../images/icon.png"
}))
The readme and documentation can be viewed here.
And the relevant ruby file that I am trying to interact with, including the author's comments, can be viewed here.
I have tried the #rubyonrails channel in IRC as well as emailing the author directly and reporting an issue at GitHub. It really is just a question of syntax.
Thanks!
Okay, so I finally got this figured out. Here's how you do it; :icon accepts a GIcon variable and :info_window_tabs accepts an array of GInfoWindowTabs. Here is how you would declare each with the plugin.
Declare GIcon
#mapper.icon_global_init(GIcon.new(:image => "../images/civil.png",
:icon_anchor => GPoint.new(0,0),
:shadow => "../images/shadow.png",
:shadow_size => GSize.new(37,32),
:info_window_anchor => GPoint.new(9,2)), "civil_icon")
#civil_icon = Variable.new("civil_icon")
Declare GInfoWindowTab
#tab1 = GInfoWindowTab.new('Tab 1 Label', 'HTML for inside of tab1')
#tab2 = GInfoWindowTab.new('Tab 2 Label', 'HTML for inside of tab2')
#window_tabs = [#tab1, #tab2]
Then in your GMarker declaration just do the following:
#mapper.overlay_init(GMarker.new([map.lat, map.lng],
:title => map.name,
:icon => #civil_icon,
:max_width => 300,
:info_window_tabs => #window_tabs))
And you're done.

Resources