Private_pub and faye gem

66 views
Skip to first unread message

a manhood

unread,
May 20, 2013, 10:52:06 PM5/20/13
to hk...@googlegroups.com
Hi, 

Anyone used private_pub and faye gem at rails 3 before ?

I can send message via using these gem. But i don't know how to use the specific channels. 

It means some of users can read the message and some don't. 

Could you please teach me ? 

Thanks,
Alex Fung

Eddie Lau (http://36613.me)

unread,
May 21, 2013, 12:33:11 AM5/21/13
to hk...@googlegroups.com
the string inside subscribe_to and publish_to is the name of the private channel
so you just need to use different value for different group of users

<%= subscribe_to "/messages/new" %>
<% publish_to "/messages/new" do %>




--
You received this message because you are subscribed to the Google Groups "Hong Kong Ruby on Rails" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hkror+un...@googlegroups.com.
To post to this group, send email to hk...@googlegroups.com.
Visit this group at http://groups.google.com/group/hkror?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

a manhood

unread,
May 21, 2013, 12:52:39 AM5/21/13
to hk...@googlegroups.com
can i add the parameter behind the messages/new ?

like, messages/new?lesson_id=x 


Eddie Lau (http://36613.me)

unread,
May 21, 2013, 1:48:35 AM5/21/13
to hk...@googlegroups.com
I think it should work.
how about lessons/:id ?

a manhood

unread,
May 21, 2013, 1:50:48 AM5/21/13
to hk...@googlegroups.com
should set the lessons/:id at route.rb ?

a manhood

unread,
May 21, 2013, 1:56:47 AM5/21/13
to hk...@googlegroups.com
at coffee script

PrivatePub.subscribe "/messages/new", (data, channel) ->
  eval data.message.content

how to add the new?lesson_id=x 

David Lawton

unread,
May 21, 2013, 2:17:22 AM5/21/13
to hk...@googlegroups.com
Lost for words
--
"I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question." -- Charles Babbage

Eddie Lau (http://36613.me)

unread,
May 21, 2013, 6:01:10 AM5/21/13
to hk...@googlegroups.com
1)
no, it is not a route
it is just a format saying that you can put the id parameter there.
sorry for confusion

again, it is just a string as the name of the channel

2)
you can pass a parameter to the function inside coffeescript
and then use the parameter to form the channel name

do you know how to concat a string in .erb or coffee script ?

a manhood

unread,
May 21, 2013, 6:04:18 AM5/21/13
to hk...@googlegroups.com

could you please teach me how to do ? i dont know how to concat at coffee script

many many thanks

David Lawton

unread,
May 21, 2013, 6:27:23 AM5/21/13
to hk...@googlegroups.com
RTFM buddy. You will learn a lot quicker


On Tuesday, 21 May 2013, a manhood wrote:

a manhood

unread,
May 21, 2013, 11:59:58 AM5/21/13
to hk...@googlegroups.com
messages.js.coffee


PrivatePub.subscribe "/messages/new", (data, channel) ->
  eval data.message.content

May i know how to add the parameter lesson_id to the /messages/new ?

many thanks,
Alex

David Lawton

unread,
May 21, 2013, 12:02:38 PM5/21/13
to hk...@googlegroups.com
Alex, 

May I ask if this is a personal project or for a company you work for?

The reason I ask is simple. The answer to my question will be revealed when you show your hand. 

Matthew Rudy Jacobs

unread,
May 21, 2013, 12:03:16 PM5/21/13
to hk...@googlegroups.com

I think you already answered this question.

you want "/messages/new?some=param"

Eddie told you to look at string interpolation.

so take a look.

a manhood

unread,
May 21, 2013, 12:07:33 PM5/21/13
to hk...@googlegroups.com
To David, it is a personal project.

Matthew, yes. i am reading the cookbook of coffee script. I am so new use coffee script. 

a manhood

unread,
May 21, 2013, 12:11:12 PM5/21/13
to hk...@googlegroups.com
so sorry for raising so many questions which may disturb you guys.

But i am really loving to code ruby on rails and building some applications

thanks,
Alex

David Lawton

unread,
May 21, 2013, 12:15:56 PM5/21/13
to hk...@googlegroups.com
Ok. 

Reason I asked is this. If its a project for a company, they should be paying to tutor you, at best, or have hired you because you know this stuff already, normal. 

How I learned, and I'm sure Matt, Steve etc learned is by trial and error, and by self learning through blogs, books and GOOGLE. 

asking people now and again for pointers on some edgecase is fine. 

Asking absolute basics, and essentially asking for answers on how to do something, rather than why something is done (I hope you understand what I mean), is a bit of a pisstake. 

I don't know python, earlang or machine code, but I sure as hell would only be asking people why something is done a certain way rather than "please give me the answers"

I do t post very much on here, or other groups, because of this kind of "give me all the answers. I WANT ALL THE THINGS WITHOUT RESEARCHING " attitude. 

Your queation may, I give you the benefit of the doubt, have come across in a way you did not intend too, but please RTFM on basics - all more than available on google - before asking on here. 

It's honestly the best wy to learn. 

Sorry if this has come across harshly, but you can't expect to learn by others giving answers. You must walk the path yourself to achieve enlightenment. 

a manhood

unread,
May 21, 2013, 12:28:59 PM5/21/13
to hk...@googlegroups.com
David, i totally agree with you.

I am not studying a computer degree at university and learn ruby on rails by myself for few years as i love programming. I kept coding many rails applications and tired to use new gems.....

Actually, i always Google when i face coding problem. May be my basic skill is not really good. When i face some problems that is new to me, sometimes i will ask people after i can not find the solution from Google.

For this case, Faye and private_pub gem, they are new to me and something about coffee script, coffeescript is very new to me. And i can not find any hints to solve problem via google. So, i type and ask. I wont ask the answer here without paying the effort (Google the answer first before asking). I really search for few days to use these 2 gems and solving this problem.

Once again, sorry for causing inconvenient and thanks David to talk with me.

Thanks,
Alex


--

David Lawton

unread,
May 21, 2013, 12:45:51 PM5/21/13
to hk...@googlegroups.com
maybe the problem is as simple as you dont know what to search for?

if you ask "what is is called in ruby when you use a variable in a string?" that would be better no? as it would help you with restricting your google search?

The answer BTW is string interpolation

do a search for "string interpolation in coffeescript", you will get the answer you seek

a manhood

unread,
May 21, 2013, 12:47:55 PM5/21/13
to hk...@googlegroups.com
yes. david, looking tutorial at string interpolation in coffeescript and trying to solve....

David Lawton

unread,
May 21, 2013, 12:49:10 PM5/21/13
to hk...@googlegroups.com
Much easier to ask what to search for rather than what the answer is.  You agree?
--
You must walk the path yourself to achieve enlightenment - Dave the Ninja

a manhood

unread,
May 21, 2013, 12:53:18 PM5/21/13
to hk...@googlegroups.com

yes of course agree....

--

David Lawton

unread,
May 21, 2013, 12:54:50 PM5/21/13
to hk...@googlegroups.com
Excellent. So from this point forward, you will ask for what to search and the name of the thing your trying to search, maybe even what the thing your trying to search means?

Yeh?

yes of course agree....

You received this message because you are subscribed to the Google Groups "Hong Kong Ruby on Rails" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hkror+un...@googlegroups.com.
To post to this group, send email to hk...@googlegroups.com.
Visit this group at http://groups.google.com/group/hkror?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "Hong Kong Ruby on Rails" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hkror+un...@googlegroups.com.
To post to this group, send email to hk...@googlegroups.com.
Visit this group at http://groups.google.com/group/hkror?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

a manhood

unread,
May 21, 2013, 12:56:13 PM5/21/13
to hk...@googlegroups.com

yes...

David Lawton

unread,
May 21, 2013, 12:57:04 PM5/21/13
to hk...@googlegroups.com
Great news, and more than happy to help you. 


On Wednesday, 22 May 2013, a manhood wrote:

yes...

On 22/05/2013 12:54 AM, "David Lawton" <da...@davetheninja.net> wrote:
Excellent. So from this point forward, you will ask for what to search and the name of the thing your trying to search, maybe evewn what the thing your trying to search means?

Francis Chong

unread,
May 21, 2013, 1:04:09 PM5/21/13
to hk...@googlegroups.com
Hi Alex

You dont need to have a computer science degree to learn programming. But you really need to study the language syntax and basic api before start programming. If you dont even know how to concat string, how can you suppose to write messaging application with it? 

Even you googled or get answer from someone else, you will not go very far. Learning while developing a project interested you is a good start, but you really learn how to learn.

Francis

-- 
Francis Chong
Ignition Soft

a manhood

unread,
May 22, 2013, 4:59:02 AM5/22/13
to hk...@googlegroups.com
Finally, solved the problem. 

/messages/new?lesson_id=#{x} is not working

but messages/new/#{x} IS WORKING. 

Thanks all
Reply all
Reply to author
Forward
0 new messages