How to call function from controller?

30 views
Skip to first unread message

can2nac

unread,
Dec 8, 2015, 11:13:32 AM12/8/15
to ChicagoBoss
Hi,

let's say i have 
-module(sns_main_controller, [Req]) which processes web requests. It also has some additional functions which i would like to call.


i can call sns_main_controller:module_info() and it returns pretty much everything, but all non /0 functions have +1 extra argument. For example, {checkCashe,4} instead of {checkCashe,3} as in description.

I tried to call function with no luck:
(sns@can2nac-laptop)12> sns_main_controller:chec   
chechCache/4  checkCashe/4  
(sns@can2nac-laptop)12> sns_main_controller:checkCashe(a,b,c,d).
** exception error: no function clause matching sns_main_controller:checkCashe(a,b,c,d) (/home/can2nac/projects/sns/src/controller/sns_main_controller.erl, line 6)
(sns@can2nac-laptop)13> sns_main_controller:checkCashe(b,c,d).  
** exception error: undefined function sns_main_controller:checkCashe/3

 How to call function from controller and what is this extra argument?

best,

kotedo

unread,
Dec 8, 2015, 11:32:24 AM12/8/15
to chica...@googlegroups.com
The best way to call these controller functions is by using API calls found here:


API calls:
{redirect, Location}

or 

{action_other, OtherLocation}

or

{render, OtherLocation}

—Kai

--
You received this message because you are subscribed to the Google Groups "ChicagoBoss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chicagoboss...@googlegroups.com.
Visit this group at http://groups.google.com/group/chicagoboss.
To view this discussion on the web visit https://groups.google.com/d/msgid/chicagoboss/5a426f69-0f2c-4741-8eef-5e3f6b01bb79%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Slava P.

unread,
Dec 8, 2015, 12:47:15 PM12/8/15
to chica...@googlegroups.com

I would like to call controller function from my code, not from controller

08.12.2015 19:32 пользователь "kotedo" <kot...@gmail.com> написал:
You received this message because you are subscribed to a topic in the Google Groups "ChicagoBoss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/chicagoboss/zQoojahsXGM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to chicagoboss...@googlegroups.com.

Jesse Gumm

unread,
Dec 8, 2015, 1:40:53 PM12/8/15
to chica...@googlegroups.com

The extra argument is the [Req] as defined in the the module definition.

Here are some slides I made up for a talk a few years back that show how parameter modules *really* work:

http://slides.sigma-star.com/view/Erlang%20Gotchas#/15

--
Jesse Gumm
Owner, Sigma Star Systems
414.940.4866 || sigma-star.com || @jessegumm

--

Slava P.

unread,
Dec 8, 2015, 1:46:08 PM12/8/15
to chica...@googlegroups.com

Thanks. I may move required functions to another custom module. This would work for me, but I appreciate you help.

Thanks

08.12.2015 21:40 пользователь "Jesse Gumm" <gu...@sigma-star.com> написал:
You received this message because you are subscribed to a topic in the Google Groups "ChicagoBoss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/chicagoboss/zQoojahsXGM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to chicagoboss...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages